Пример #1
0
// Done with message, delete it or mark it unused
void OsMsg::releaseMsg()
{
   if (isMsgReusable()) {
      setInUse(FALSE);
   } else {
      delete this;
   }
}
ProfileObjectView &ProfileObject :: view ( )
  {
  if ( !objView )
    {
    objView = this -> newView();
    setInUse( true );
    }
  return *objView;
  }
Пример #3
0
// add a next setpoint for the stepper to go to, will wait if queue is full
void setpointAdd (const Setpoint& s) {
    // TODO: silly approach, should use first/last indices into circular buffer
    for (int i = 0; i <= SETPOINT_QUEUE_SIZE; ++i)
        if (!isInUse(i)) {
            setInUse(i);
            setpoint.setpoints[i] = s;
            chMBPost(&setpoint.mailbox, i, TIME_INFINITE);
            return;
        }
    // never reached
}
Пример #4
0
void DIVMDKBlockStorage::close()
{
    // Unmark in use
    setInUse(false);
    
    backingStore = NULL;
    
    blockNum = 0;
    
    cylinders = 0;
    heads = 0;
    sectors = 0;
    
    grainSize = 0;
    grainTableSize = 0;
    directory1Block = 0;
    directory2Block = 0;
    redundantDirectory = false;
    allocatedBlockNum = 0;
    
    metadata.clear();
}
ProfileObject &ProfileObject :: viewClosed ( )
  {
  this->objView = 0;
  setInUse( false );
  return *this;
  }
Пример #6
0
bool DIVMDKBlockStorage::open(DIBackingStore *backingStore)
{
    close();
    
    DIChar header[VMDK_HEADERSIZE];
    
    if (!backingStore->read(0, header, VMDK_HEADERSIZE))
        return false;
    
    // Check VMDK id
    if (getDIIntLE(&header[0x0]) != 0x564d444b)
        return false;
    
    // Check VMDK version
    DIInt version = getDIIntLE(&header[0x4]);
    if ((version != 1) && (version != 2))
        return false;
    
    // Get VMDK flags
    DIInt flags = getDIIntLE(&header[0x8]);
    
    redundantDirectory = (flags & (1 << 1));
    
    // Get VMDK capacity
    blockNum = (DIInt) getDILongLE(&header[0xc]);
    
    // Get VMDK grain info
    grainSize = (DIInt) getDILongLE(&header[0x14]);
    grainTableSize = getDIIntLE(&header[0x2c]);
    directory1Block = (DIInt) getDILongLE(&header[0x38]);
    directory2Block = (DIInt) getDILongLE(&header[0x30]);
    DIInt dataBlock = (DIInt) getDILongLE(&header[0x40]);
    
    // Get descriptor
    DILong descriptorOffset = getDILongLE(&header[0x1c]);
    DILong descriptorSize = getDILongLE(&header[0x24]);
    
    if (!parseDescriptor(backingStore, descriptorOffset, (DIInt) descriptorSize))
        return false;
    
    // Do not accept compression
    if ((flags & (1 << 16)) && (getDIShortLE(&header[0x4d]) != 0))
        return false;
    
    // Verify clean shutdown
    if (header[0x48])
        return false;
    
    // Read metadata
    DIData data;
    
    data.resize(dataBlock * DI_BLOCKSIZE);
    
    if (!backingStore->read(0, &data.front(), (DIInt) data.size()))
        return false;
    
    metadata.resize(data.size() / sizeof(DIInt));
    for (DIInt i = 0; i < metadata.size(); i++)
        metadata[i] = getDIIntLE(&data[i * sizeof(DIInt)]);
    
    directoryEntrySize = grainTableSize * grainSize;
    
    // Mark in use
    setInUse(true);
    
    this->backingStore = backingStore;
    
    return true;
}