Esempio n. 1
0
/*-----------------------------------------------------------------------------*
 * This routine transfers the script program image into the script engine's
 * on-board ram
 *
 *-----------------------------------------------------------------------------*/
void Sym8xxSCSIController::Sym8xxLoadScript( UInt32 *scriptPgm,  UInt32 scriptWords )
{
    UInt32			i;
    volatile UInt32		*ramPtr = (volatile UInt32 *)chipRamAddr;

    for ( i = 0; i < scriptWords; i++ )
    {
        ramPtr[i] = OSSwapHostToLittleInt32(scriptPgm[i]);
    }
}
Esempio n. 2
0
//message composer
void CEchoSrvDataChannel::SendMessage(DWORD message, char *data, unsigned int datalen)
{
	char*	lpBuf = NULL;
	DWORD	nBytesSent = 0;

	CProxyMsg msg(message );

	NetPacketHeader header;

	header.len = msg.MakeMessage(&header, lpBuf, data, datalen); //create the message

	DWORD dwToSend = OSSwapHostToLittleInt32(header.len + sizeof(DWORD));
	m_pSendBuffer->Write(&dwToSend, sizeof(DWORD));
	m_pSendBuffer->Write(lpBuf, header.len);
	Send();

	if (lpBuf)
		delete lpBuf;
}
Esempio n. 3
0
UInt32 Sym8xxSCSIController::Sym8xxReadRegs( volatile UInt8 *chipRegs, UInt32 regOffset, UInt32 regSize )
{
    if ( regSize == 1 )
    {
        return chipRegs[regOffset];
    }
    if ( regSize == 2 )
    {
        return OSSwapHostToLittleInt16( *(volatile u_int16_t *)&chipRegs[regOffset] );
    }
    else if (regSize == 4 )
    {
        return OSSwapHostToLittleInt32( *(volatile UInt32 *)&chipRegs[regOffset] );
    }
    else
    {
        kprintf("SCSI(SymBios875): Sym8xxReadRegs incorrect regSize\n\r" );
        return 0;
    } 
}
Esempio n. 4
0
static char *get_fallback(void *priv, const char *family, uint32_t codepoint)
{
    CFStringRef name = CFStringCreateWithBytes(
        0, (UInt8 *)family, strlen(family), kCFStringEncodingUTF8, false);
    CTFontRef font = CTFontCreateWithName(name, 0, NULL);
    uint32_t codepointle = OSSwapHostToLittleInt32(codepoint);
    CFStringRef r = CFStringCreateWithBytes(
        0, (UInt8*)&codepointle, sizeof(codepointle),
        kCFStringEncodingUTF32LE, false);
    CTFontRef fb = CTFontCreateForString(font, r, CFRangeMake(0, 1));
    CFStringRef cffamily = CTFontCopyFamilyName(fb);
    char *res_family = cfstr2buf(cffamily);

    SAFE_CFRelease(name);
    SAFE_CFRelease(font);
    SAFE_CFRelease(r);
    SAFE_CFRelease(fb);
    SAFE_CFRelease(cffamily);

    return res_family;
}
Esempio n. 5
0
static void
EncryptPwBlockWithPasswordHash(const uint8_t * password,
			       uint32_t password_len,
			       const uint8_t pw_hash[NT_PASSWORD_HASH_SIZE],
			       NTPasswordBlockRef pwblock)
{
    NTPasswordBlock	clear_pwblock;
    int			offset;
    uint32_t		password_len_little_endian;

    MSChapFillWithRandom(&clear_pwblock, sizeof(clear_pwblock));
    offset = sizeof(clear_pwblock.password) - password_len;
    bcopy(password, ((void *)&clear_pwblock) + offset, password_len);
    /* convert password length to little endian */
    password_len_little_endian = OSSwapHostToLittleInt32(password_len);
    bcopy(&password_len_little_endian, clear_pwblock.password_length,
	  sizeof(uint32_t));
    rc4_encrypt(&clear_pwblock, sizeof(clear_pwblock),
		pw_hash, NT_PASSWORD_HASH_SIZE, pwblock);
    return;
}
Esempio n. 6
0
void Sym8xxSCSIController::Sym8xxWriteRegs( volatile UInt8 *chipRegs, UInt32 regOffset, UInt32 regSize, UInt32 regValue )
{
    if ( regSize == 1 )
    {
        chipRegs[regOffset] = regValue;
    }
    else if ( regSize == 2 )
    {
        volatile u_int16_t *p = (volatile u_int16_t *)&chipRegs[regOffset];
        *p = OSSwapHostToLittleInt16( regValue );
    }
    else if ( regSize == 4 )
    {
        volatile UInt32 *p = (volatile UInt32 *)&chipRegs[regOffset];
        *p = OSSwapHostToLittleInt32( regValue );
    }
    else
    {
        kprintf("SCSI(SymBios875): Sym8xxWriteRegs incorrect regSize\n\r" );
    }
    eieio();
}
Esempio n. 7
0
/*-----------------------------------------------------------------------------*
 *
 *-----------------------------------------------------------------------------*/
void Sym8xxSCSIController::executeCommand( IOSCSIParallelCommand *scsiCommand )
{
    SRB				*srb = NULL;
    SCSICDBInfo			scsiCDB;
    SCSITargetLun               targetLun;
    Nexus                       *nexus;
    Nexus                       *nexusPhys;  
    UInt32                      len;  
    bool                        isWrite;                
    IOMemoryDescriptor		* iomd;

    srb = (SRB *) scsiCommand->getCommandData();
    bzero( srb, sizeof(SRB) );

    srb->scsiCommand = scsiCommand;

    scsiCommand->getCDB( &scsiCDB );
    scsiCommand->getTargetLun( &targetLun );
    
    srb->target      = targetLun.target;
    srb->lun         = targetLun.lun;
    srb->srbCDBFlags = scsiCDB.cdbFlags;

    // 1 IOMD per target, since only 1 transaction possible with current architecture
    iomd             = SCSI_IOMDs[(int) srb->target ];
    srb->srbIOMD     = iomd;
    // ::initWithAddress() causes any previous IOMDs to be ::complete()'d
    if ( iomd->initWithAddress( srb, sizeof( SRB ), kIODirectionOutIn ) )
    {
	iomd->prepare();
	srb->srbPhys = (SRB *) iomd->getPhysicalAddress();
    }
    else
    {
	// this should never happen, as we have allocated enough
	// IOMDs for MAX_SCSI_TARGETS plus 1 extra for reset
	panic( "Sym8xxSCSIController::executeCommand - IOMemoryDescriptor reinitialization failed" );
    }

    /*
     * Setup the Nexus struct. This part of the SRB is read/written both by the
     * script and the driver.
     */

    nexus                     = &srb->nexus;
    nexusPhys                 = &srb->srbPhys->nexus;
    nexus->targetParms.target = srb->target;

//    printf( "SCSI(Symbios8xx): executeCommand: T/L = %d:%d Cmd = %08x CmdType = %d\n\r", 
//                        targetLun.target, targetLun.lun, (int)scsiCommand, scsiCommand->getCmdType() );
    
    switch ( scsiCommand->getCmdType() )
    {
        case kSCSICommandAbort:
        case kSCSICommandAbortAll:
        case kSCSICommandDeviceReset:
            Sym8xxAbortCommand( scsiCommand );
            return;

        default:
            ;
    }
    
    /*
     * Set client data buffer pointers in the SRB
     */
    scsiCommand->getPointers( &srb->xferDesc, &srb->xferCount, &isWrite );
    
    srb->directionMask = (isWrite) ? 0x00000000 :0x01000000;    
    
    nexus->cdb.ppData = OSSwapHostToLittleInt32((UInt32)&nexusPhys->cdbData);

    len = scsiCDB.cdbLength;

    nexus->cdb.length = OSSwapHostToLittleInt32( len );
    // implicit copying of arrays is not desireable.  explicitly spell out what is being copied
    // [rdar://problem/4092008]
    // nexus->cdbData    = scsiCDB.cdb;
    bcopy( &scsiCDB.cdb, &nexus->cdbData, sizeof( nexus->cdbData ) );

    Sym8xxCalcMsgs( scsiCommand );
    
    /*
     * Setup initial data transfer list (SGList) 
     */
    nexus->ppSGList   = (SGEntry *)OSSwapHostToLittleInt32((UInt32)&nexusPhys->sgListData[2]);
    Sym8xxUpdateSGList( srb );

    Sym8xxStartSRB( srb );
}
Esempio n. 8
0
/*-----------------------------------------------------------------------------*
 * This routine creates SCSI messages to send during the initial connection
 * to the target. It is called during client request processing and also by
 * the I/O thread when a request sense operation is required.
 *
 * Outbound messages are setup in the MsgOut buffer in the Nexus structure of
 * the SRB.
 *
 *-----------------------------------------------------------------------------*/
void Sym8xxSCSIController::Sym8xxCalcMsgs( IOSCSIParallelCommand *scsiCommand ) 
{
    SRB			*srb;
    Nexus		*nexus;
    Nexus		*nexusPhys;
    UInt32		msgIndex;
    SCSICDBInfo		scsiCDB;
    SCSITargetParms	targetParms;
    UInt32		i;
    UInt32		tw;


    srb       = (SRB *)scsiCommand->getCommandData();
    nexus     = &srb->nexus;
    nexusPhys = &srb->srbPhys->nexus;

    scsiCommand->getCDB( &scsiCDB );

    /*
     * Setup Identify message 
     */
    msgIndex = 0;
    nexus->msg.ppData = OSSwapHostToLittleInt32((UInt32)&nexusPhys->msgData);
    nexus->msgData[msgIndex++] = srb->lun | (( scsiCDB.cdbFlags & kCDBFlagsNoDisconnect ) ? 0x80 : 0xC0);

    /*
     * Allocate tag for request.
     *
     * For non-tagged requests a pseudo-tag is created consisting of target*16+lun. For tagged
     * requests a tag in the range 128-255 is allocated.
     *
     * If a pseudo-tag is inuse for a non-tagged command or there are no tags available for
     * a tagged request, then the command is blocked until a tag becomes available.
     *
     * Note: If we are being called during request sense processing (srbState != ksrbStateCDBDone)
     *       then a tag has already been allocated to the request.
     */
    if ( scsiCDB.cdbTagMsg != 0 )
    {
        nexus->msgData[msgIndex++] = scsiCDB.cdbTagMsg;
        nexus->msgData[msgIndex++] = srb->tag = srb->nexus.tag = scsiCDB.cdbTag + 128;
    }
    else
    {
        srb->tag = srb->nexus.tag = ((UInt32)srb->target << 3) | srb->lun;
    }   
    /*
     * Setup to negotiate for Wide (16-bit) data transfers
     *
     * Note: There is no provision to negotiate back to narrow transfers although
     *       SCSI does support this.
     */
        
    scsiCommand->getDevice(kIOSCSIParallelDevice)->getTargetParms( &targetParms );

    if ( scsiCDB.cdbFlags & (kCDBFlagsNegotiateWDTR | kCDBFlagsNegotiateSDTR) )
    {
        negotiateWDTRComplete = negotiateSDTRComplete = false;
    }

    if ( scsiCDB.cdbFlags & kCDBFlagsNegotiateWDTR )
    {
        nexus->msgData[msgIndex++] = kSCSIMsgExtended;
        nexus->msgData[msgIndex++] = 2;
        nexus->msgData[msgIndex++] = kSCSIMsgWideDataXferReq;

        for ( tw = targetParms.transferWidth, i = (UInt32)-1; 
              tw; 
              tw >>= 1, i++ )
          ;

        nexus->msgData[msgIndex++] = i;
    }
Esempio n. 9
0
uint32_t tole32(uint32_t x) { return OSSwapHostToLittleInt32(x); }