3ware RAID driver

Joined
Aug 5, 2009
Messages
4
Reaction score
0
Points
1
Location
Vilnius
Hi
I'm new to programming, for OS X in particular (not the IT itself). Any way I'm forced to make the first steps towards.
The reason is an urge need in driver for a 3ware Escalade 7xxx/8xxx PATA/SATA-RAID Controller. 3ware officially doesn't provide any. Only 9xxx cards are supported. My idea was to write the missing driver using AMCC3ware9000.kext as reference. The results are not as good as expected. I made following steps with Xcode:
1) Composed new info.plist (based on the info.plist from AMCC3ware9000.kext)
2) Composed .h and .cpp source (based on sample codes I've found in WEB)
3) Compiled binary
4) Loaded kext (the kext loads with no problems or bugs, but does nothing else)
There is an output on the system boot:
Aug 0 00:00:00 localhost kernel[0]: com_amcc_3ware_AMCC3ware7xxx8xxxController[0x665db00]::probe(0x663b380, 0x5ba23f0c)
Aug 0 00:00:00 localhost kernel[0]: com_amcc_3ware_AMCC3ware7xxx8xxxController[0x665db00]::start(0x663b380)

As far as I understand the *UserClient.h *UserClient.cpp are needed in this case for the driver to be fully functional. The is the point I can't go any further. The *UserClient.h *UserClient.cpp sources I've managed to create, doesn't compile. Compilation gives 56 (or so) errors. To make things simpler, I've attached the Xcode project. I need an advice on debugging and recomposing the source (in other words what needs to be changed or modified).

View attachment AMCC3ware7xxx8xxx.zip
 
Joined
Aug 5, 2009
Messages
1
Reaction score
0
Points
1
Just wanted to say hello

Hi guys..Glad to be here and looking forward to learning some new stuff!
 
OP
D
Joined
Aug 5, 2009
Messages
4
Reaction score
0
Points
1
Location
Vilnius
Further development

I'm currently developing newer driver version based on Linux/BSD and some other sources. The project is currently in debugging stage. The question is what exactly cosign those bugs? There is an error log with "problematic" code lines.

Line Location TemagoCommand.cpp:350: note: candidates are: virtual void com_Inc_TemagoCommand::complete(bool)
Line Location TemagoCommand.cpp:352: error: 'IOStorageCompletion' was not declared in this scope
Line Location TemagoCommand.cpp:352: error: expected `;' before 'localCompletion'
Line Location TemagoCommand.cpp:379: error: 'localCompletion' was not declared in this scope
Line Location TemagoCommand.cpp:379: error: 'completion' was not declared in this scope
Line Location TemagoCommand.cpp:392: error: 'IOStorage' has not been declared
Line Location TemagoCommand.cpp:394: error: no matching function for call to 'com_Inc_TemagoCommand::complete(<type error>, int, long long unsigned int)'
Code:
// Handle completion of a command
//
// Note that this may be called either inside or outside the gate.
void
line 350 self::complete(bool postSuccess)
{
    IOStorageCompletion localCompletion;
    IOByteCount	actualByteCount;
    bool	result;

    postResult = postSuccess;
    
    command->complete(kIODirectionOutIn);
    dequeueActive();
    
    // auto-complete if we have a parameter buffer
    if (paramBuffer != NULL)
	paramBuffer->complete(kIODirectionOutIn);

    // if we have a copy buffer, finalise it
    if (copyBuffer != NULL)
	finishCopyBuffer();

    // data buffers for SET_PARAM auto-release here
    if (commandPtr->generic.opcode == TWE_OP_SET_PARAM)
	releaseParamBuffer();

    // Wake up a sleeping owner.
    // Owner is responsible for returning the command.
    if (waitingOwner) {
	controller->wakeCommand(this);
    } else {
	// save because we are going to release command first
	localCompletion = completion;
	actualByteCount = byteCount;
	result = getResult();
	if (!result) {
	    debug(2, "I/O error 0x%02x/ox%02x", (uint)commandPtr->generic.status, (uint)commandPtr->generic.flags);
	    print();
	}
	// Command submitter is gone, completion may know nothing
	// about our command, so we have to tear it down it ourselves.
	releaseDataBuffer();
	returnCommand();

	// Invoke completion
	IOStorage::complete(localCompletion,
		     result ? kIOReturnSuccess : kIOReturnError,
line 394	     result ? byteCount : 0);
    }
}
Line Location TemagoCommand.cpp:562: error: 'IOStorageCompletion' has not been declared
Line Location TemagoCommand.cpp:577: error: 'completion' was not declared in this scope
Code:
////////////////////////////////////////////////////////////////////////////////
// Build an I/O command
void
self::makeReadWrite(int unit,
		    IOMemoryDescriptor *buf,
		    UInt32 block,
		    UInt32 nblks,
line 562	    IOStorageCompletion withCompletion)
{

    // select opcode
    if (buf->getDirection() == kIODirectionOut) {
	commandPtr->io.opcode = TWE_OP_WRITE;
    } else {
	commandPtr->io.opcode = TWE_OP_READ;
    }
    commandPtr->io.size = 3;
    commandPtr->io.host_unit = unit;
    commandPtr->io.status = 0;
    commandPtr->io.flags = 0;
    commandPtr->io.block_count = OSSwapHostToLittleInt16((UInt16)nblks);
    commandPtr->io.lba = OSSwapHostToLittleInt32(block);
line 577    completion = withCompletion;
    setDataBuffer(buf);
}
End of part one
 
OP
D
Joined
Aug 5, 2009
Messages
4
Reaction score
0
Points
1
Location
Vilnius
Futher development

Part two
Line Location TemagoCommand.h:79: error: 'IOStorageCompletion' has not been declared
Line Location TemagoCommand.h:134: error: 'IOStorageCompletion' does not name a type
Code:
    // Command mutators
    //
    virtual void	makeInitConnection(UInt32 credits);
    virtual void	makeGetParam(int table, int param, size_t size);
    virtual void	makeSetParam(int table, int param, UInt8 value);
    virtual void	makeSetParam(int table, int param, UInt16 value);
    virtual void	makeSetParam(int table, int param, UInt32 value);
    virtual void	makeSetParam(int table, int param, void *vp, size_t vsize);
    virtual void	makeFlush(int unit);
    virtual void	makeReadWrite(int unit, IOMemoryDescriptor *buf, UInt32 block, UInt32 nblks,
line 79			       IOStorageCompletion withCompletion);
    virtual void	makePowerSave(int state);	// 0 = spin down

    // temporary buffer, used to align unaligned requests
    IOBufferMemoryDescriptor	*copyBuffer;
    IOMemoryDescriptor		*realBuffer;

    // completion, set by ::makeReadWrite
line 134    IOStorageCompletion		completion;
Line Location TemagoController.cpp:993: error: 'IOStorageCompletion' has not been declared
Line Location TemagoController.cpp:1068: error: 'class com_Inc_TemagoDrive' has no member named 'isOpen'
Line Location TemagoController.cpp:1075: error: 'class com_Inc_TemagoDrive' has no member named 'terminate'
Line Location TemagoController.cpp:1152: error: 'class com_Inc_TemagoDrive' has no member named 'init'
Line Location TemagoController.cpp:1155: error: 'class com_Inc_TemagoDrive' has no member named 'release'
Line Location TemagoController.cpp:1164: error: 'class com_Inc_TemagoDrive' has no member named 'registerService'
Line Location TemagoController.cpp:1169: error: 'class com_Inc_TemagoDrive' has no member named 'release'
Code:
//
IOReturn
self::doAsyncReadWrite(int unit,
		       IOMemoryDescriptor *buffer,
		       UInt32 block,
		       UInt32 nblks,
line 993	       IOStorageCompletion completion)
{
    TemagoCommand	*ec;
    bool		result;

    // check that drives are spun up
    checkPowerState();

    // do I/O
    ec = getCommand();
    ec->makeReadWrite(unit, buffer, block, nblks, completion);
    result = runAsynchronousCommand(ec);
    if (!result)
	ec->returnCommand();

    return(result ? kIOReturnSuccess : kIOReturnIOError);
}

// Request termination of a given unit

IOReturn
self::doRemoveUnit(int unit, bool force)
{
    TemagoDrive	*pUnit;

    // find unit and validate
    pUnit = logicalUnit[unit];
    if (!pUnit)
	return(kIOReturnNoDevice);
line 1068    if (!force && pUnit->isOpen()) {
	error("attempt to remove busy unit %d", unit);
	return(kIOReturnBusy);
    }

    // valid, terminate unit
    debug(3, "unit %d unbusy, terminating", unit);
line 1075    pUnit->terminate();
    logicalUnit[unit] = NULL;
    return(kIOReturnSuccess);
}
    // instantiate the drive
    if ((logicalUnit[unit] = new TemagoDrive) == NULL) {
	error("could not instantiate TemagoDrive for unit %d", unit)
	return(kIOReturnNoMemory);
    }
    logicalUnit[unit]->init(NULL);
    if (!logicalUnit[unit]->attach(this)) {
	error("could not attach TemagoDrive for unit %d", unit);
line 1155	logicalUnit[unit]->release();
	logicalUnit[unit] = NULL;
	return(kIOReturnError);
    }
    logicalUnit[unit]->setUnit(unit);
    logicalUnit[unit]->setSize(size);
    logicalUnit[unit]->setConfiguration(unitType);

    // all done, register unit for discovery
line 1164    logicalUnit[unit]->registerService();

    // The IORegistry has retained the unit, so we don't here.
    // It might make sense for us to keep a reference on it
    // just in case...
    logicalUnit[unit]->release();
    
    return(kIOReturnSuccess);
}
Line Location TemagoController.h:120: error: 'IOStorageCompletion' has not been declared
Code:
    // TemagoDrive interface
    //
    virtual char		*getControllerName(void);
    virtual char		*getControllerVersion(void);
    virtual IOReturn		doAsyncReadWrite(int unit, IOMemoryDescriptor *buffer,
line 120				       UInt32 block, UInt32 nblks, IOStorageCompletion completion);
    virtual IOReturn		doSynchronizeCache(int unit);
Line Location TemagoDrive.h:40: error: expected class-name before '{' token
Code:
class TemagoController;

class TemagoDrive : public IOBlockStorageDevice
line 40{
    OSDeclareDefaultStructors(TemagoDrive);

public:
    // superclass overrides
Line Location TemagoDrive.h:54: error: 'IOStorageCompletion' has not been declared
Code:
    // IOBlockStorageDevice protocol
line 54    virtual IOReturn	doAsyncReadWrite(IOMemoryDescriptor *buffer, UInt32 block, UInt32 nblks, IOStorageCompletion completion);
    virtual IOReturn	doEjectMedia(void);
    virtual IOReturn	doFormatMedia(UInt64 byteCapacity);
    virtual UInt32	doGetFormatCapacities(UInt64 *capacities,  UInt32 capacitiesMaxCount) const;
The end. Sorry for such a long story :) Just trying to make a things clearer. Is it possible to identify the problem? Could the wrong info.plist values do such a mess?
Any help is appreciated!
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top