void Afe_Set_Reg(uint32 offset, uint32 value, uint32 mask)
{
    extern void *AFE_BASE_ADDRESS;
    volatile long address;
    volatile uint32 *AFE_Register;
    volatile uint32 val_tmp;

    if (CheckOffset(offset) == false)
    {
        return;
    }

#ifdef AUDIO_MEM_IOREMAP
    PRINTK_AUDDRV("Afe_Set_Reg AUDIO_MEM_IOREMAP AFE_BASE_ADDRESS = %p\n",AFE_BASE_ADDRESS);
    address = (long)((char *)AFE_BASE_ADDRESS + offset);
#else
    printk("%s check \n", __func__);
    address = (long)(AFE_BASE + offset);
#endif

    AFE_Register = (volatile uint32 *)address;

    PRINTK_AFE_REG("Afe_Set_Reg offset=%x, value=%x, mask=%x \n",offset,value,mask);
    val_tmp = Afe_Get_Reg(offset);
    val_tmp &= (~mask);
    val_tmp |= (value & mask);
    mt_reg_sync_writel(val_tmp, AFE_Register);
}
void Afe_Set_Reg(uint32 offset, uint32 value, uint32 mask)
{
	volatile long address;
	volatile uint32 *AFE_Register;
	volatile uint32 val_tmp;
	unsigned long flags = 0;

	if (CheckOffset(offset) == false)
		return;

#ifdef AUDIO_MEM_IOREMAP
	/* PRINTK_AUDDRV("Afe_Set_Reg AUDIO_MEM_IOREMAP AFE_BASE_ADDRESS = %p\n",AFE_BASE_ADDRESS); */
	address = (long)((char *)AFE_BASE_ADDRESS + offset);
#else
	address = (long)(AFE_BASE + offset);
#endif

	AFE_Register = (volatile uint32 *)address;
	/* PRINTK_AFE_REG("Afe_Set_Reg offset=%x, value=%x, mask=%x\n",offset,value,mask); */
	spin_lock_irqsave(&afe_set_reg_lock, flags);
	val_tmp = Afe_Get_Reg(offset);
	val_tmp &= (~mask);
	val_tmp |= (value & mask);
	mt_reg_sync_writel(val_tmp, AFE_Register);
	spin_unlock_irqrestore(&afe_set_reg_lock, flags);
}
ECode RuleBasedBreakIterator::GetFollowing(
    /* [in] */ Int32 offset,
    /* [out] */ Int32* position)
{
    VALIDATE_NOT_NULL(position);
    *position = -1;
    FAIL_RETURN(CheckOffset(offset));
    return mWrapped->GetFollowing(offset, position);
}
ECode RuleBasedBreakIterator::IsBoundary(
    /* [in] */ Int32 offset,
    /* [out] */ Boolean* isBoundary)
{
    VALIDATE_NOT_NULL(isBoundary);
    *isBoundary = FALSE;
    FAIL_RETURN(CheckOffset(offset));
    return mWrapped->IsBoundary(offset,isBoundary);
}
Exemple #5
0
static
NTSTATUS
RtlValidateSelfRelativeSid(
    PSID pSid,
    ULONG ulOffset,
    ULONG ulRelativeSize
    )
{
    NTSTATUS status = STATUS_SUCCESS;

    status = CheckOffset(ulOffset, SID_MIN_SIZE, ulRelativeSize);
    GOTO_CLEANUP_ON_STATUS(status);

    status = CheckOffset(ulOffset, RtlLengthSid(pSid), ulRelativeSize);
    GOTO_CLEANUP_ON_STATUS(status);

cleanup:

    return status;
}
Exemple #6
0
uint32 Afe_Get_Reg(uint32 offset)
{
#ifdef AUDIO_MEM_IOREMAP
    extern void *AFE_BASE_ADDRESS;
    //PRINTK_AUDDRV("Afe_Get_Reg AUDIO_MEM_IOREMAP AFE_BASE_ADDRESS = %p\ offset = %xn",AFE_BASE_ADDRESS,offset);
    volatile long address = (long)((char *)AFE_BASE_ADDRESS + offset);
#else
    volatile long address = (AFE_BASE + offset);
#endif
    volatile long *value;
    if (CheckOffset(offset) == false)
    {
        return 0;
    }
    value = (volatile long *)(address);
    //PRINTK_AFE_REG("Afe_Get_Reg offset=%x address = %x value = 0x%x\n",offset,address,*value);
    return *value;
}
uint32 Afe_Get_Reg(uint32 offset)
{
	volatile long address;
	volatile uint32 *value;

	if (CheckOffset(offset) == false)
		return 0xffffffff;

#ifdef AUDIO_MEM_IOREMAP
	/* PRINTK_AUDDRV("Afe_Get_Reg  AFE_BASE_ADDRESS = %p\ offset = %xn",AFE_BASE_ADDRESS,offset); */
	address = (long)((char *)AFE_BASE_ADDRESS + offset);
#else
	address = (long)(AFE_BASE + offset);
#endif

	value = (volatile uint32 *)(address);
	/* PRINTK_AFE_REG("Afe_Get_Reg offset=%x address = %x value = 0x%x\n",offset,address,*value); */
	return *value;
}
Exemple #8
0
/** Calculate all of the forward neighbors for each grid cell and if
  * needed which translate vector is appropriate.
  * +X: need self and offsetX cells to the "right".
  * +Y: need 2*offsetX+1 cells in "above" offsetY rows.
  * +Z: need 2*offsetX+1 by 2*offsetY+1 cells in "above" offsetZ rows.
  * The translate vector is calculated based on offset indices. The x
  * and y offset indices are actually +1 so we can calculate an index
  * via idx = oz*3*3 + oy*3 + ox. oz is either 0 or 1 since we only
  * care about forward direction.
  */
void PairList::CalcGridPointers(int myindexlo, int myindexhi) {
  //Matrix<bool> PairCalcd;
  //PairCalcd.resize(nGridMax_, 0); // Half matrix
  //std::fill(PairCalcd.begin(), PairCalcd.end(), false);
  //  int idx = (i3*nGridX_*nGridY_)+(i2*nGridX_)+i1;
  int offsetX = cellOffset_;
  int offsetY = cellOffset_;
  int offsetZ = cellOffset_;
  // Check the cell offsets. If they are too big comared to the grid
  // size we will end up calculating too many values.
  CheckOffset(nGridX_, offsetX, 'X');
  CheckOffset(nGridY_, offsetY, 'Y');
  CheckOffset(nGridZ_, offsetZ, 'Z');

  int NP_ = 0;
  int nGridXY = nGridX_ * nGridY_;
  for (int nz = 0; nz != nGridZ_; nz++)
  {
    int idx3 = nz * nGridXY;
    for (int ny = 0; ny != nGridY_; ny++)
    {
      int idx2 = idx3 + (ny*nGridX_);
      for (int nx = 0; nx != nGridX_; nx++)
      {
        int idx = idx2 + nx; // Absolute grid cell index
        if (idx >= myindexlo && idx < myindexhi) {
          Iarray& Nbr = cells_[idx].neighborPtr_;
          Iarray& Ntr = cells_[idx].neighborTrans_;
          //int NP = 0;
//          mprintf("DBG: Cell %3i%3i%3i (%i):", nx,ny,nz, idx);
          // Get this cell and all cells ahead in the X direction.
          // This cell is always a "neighbor" of itself.
          int maxX = nx + offsetX + 1;
          for (int ix = nx; ix < maxX; ix++, NP_++) {
            // Wrap ix if necessary
            if (ix < nGridX_) {
//              mprintf(" %i+0", idx2+ix);
              Nbr.push_back( idx2 + ix );
              Ntr.push_back( 4 ); // No translation. 0 0 0
            } else {
//              mprintf(" %i+1", idx2+ix - nGridX_);
              Nbr.push_back( idx2 + ix - nGridX_ );
              Ntr.push_back( 5 ); // Translate by +1 in X. 1 0 0
            }
          }
          // Get all cells in the Y+ direction
          int minX = nx - offsetX;
          int minY = ny + 1;
          int maxY = ny + offsetY + 1;
          for (int iy = minY; iy < maxY; iy++) {
            // Wrap iy if necessary
            int wy, oy;
            if (iy < nGridY_) {
              wy = iy;
              oy = 1; // 0
            } else {
              wy = iy - nGridY_;
              oy = 2; // 1
            }
            int jdx2 = idx3 + (wy*nGridX_);
            for (int ix = minX; ix < maxX; ix++, NP_++) {
              // Wrap ix if necessary
              int wx, ox;
              if (ix < 0) {
                wx = ix + nGridX_;
                ox = 0; // -1
              } else if (ix < nGridX_) {
                wx = ix;
                ox = 1; // 0
              } else {
                wx = ix - nGridX_;
                ox = 2; // 1
              }
              // Calc new index
              int jdx = jdx2 + wx; // Absolute neighbor grid cell index
//              mprintf(" %i%+i%+i", jdx, ox-1, oy-1);
              Nbr.push_back( jdx );
              int tidx = oy*3 + ox;
              Ntr.push_back( tidx );
            }
          }
          // Get all cells in the +Z direction
          int minZ = nz + 1;
          int maxZ = nz + offsetZ + 1;
          for (int iz = minZ; iz < maxZ; iz++) {
            // Wrap iz if necessary
            int wz, oz;
            if (iz < nGridZ_) {
              wz = iz;
              oz = 0; // 0
            } else {
              wz = iz - nGridZ_;
              oz = 1; // 1
            }
            int jdx3 = wz * nGridXY;
            minY = ny - offsetY;
            for (int iy = minY; iy < maxY; iy++) {
              // Wrap iy if necessary
              int wy, oy;
              if (iy < 0) {
                wy = iy + nGridY_;
                oy = 0; // -1
              } else if (iy < nGridY_) {
                wy = iy;
                oy = 1; // 0
              } else {
                wy = iy - nGridY_;
                oy = 2; // 1
              }
              int jdx2 = jdx3 + (wy*nGridX_);
              for (int ix = minX; ix < maxX; ix++, NP_++) {
                // Wrap ix if necessary
                int wx, ox;
                if (ix < 0) {
                  wx = ix + nGridX_;
                  ox = 0; // -1
                } else if (ix < nGridX_) {
                  wx = ix;
                  ox = 1; // 0
                } else {
                  wx = ix - nGridX_;
                  ox = 2; // 1
                }
                // Calc new index
                int jdx = jdx2 + wx; // Absolute neighbor grid cell index
//                mprintf(" %i%+i%+i%+i", jdx, ox-1, oy-1, oz);
                Nbr.push_back( jdx );
                int tidx = oz*9 + oy*3 + ox;
                Ntr.push_back( tidx );
              }
            }
          }

//          mprintf("\n");
          //if (NP > maxNptrs_) {
          //  mprinterr("Error: You overflowed! (%i)\n", NP);
          //  return;
          //}
//          mprintf("Grid %3i%3i%3i (%i): %zu neighbors\n", nx,ny,nz, idx, Nbr.size());
//          for (unsigned int i = 0; i != Nbr.size(); i++)
//            mprintf("\t%i [%i]\n", Nbr[i], Ntr[i]);
          //mprintf("\n");
/*          for (unsigned int i = 0; i != Nbr.size(); i++) {
            if (PairCalcd.element(idx,Nbr[i]))
              mprintf("Warning: Interaction %i %i already calcd.\n", idx, Nbr[i]);
            else
              PairCalcd.setElement(idx,Nbr[i], true);
          }*/
        } // END my cell
      } // nx
    } // ny
  } // nz
}
Exemple #9
0
	void Read(OFFSET offset, u8* data, u32 size)
	{
		CheckOffset(offset, size);

		memcpy(data, disk+offset, size);
	}
Exemple #10
0
	void Write(OFFSET offset, u8* data, u32 size)
	{
		CheckOffset(offset, size);

		memcpy(disk+offset, data, size);
	}
Exemple #11
0
	void Read(OFFSET offset, u8* data, u32 size)
	{
		CheckOffset(offset, size);
		MoveFilePointer(offset);
		fread(data, size, 1, file);
	}
Exemple #12
0
	void Write(OFFSET offset, u8* data, u32 size)
	{
		CheckOffset(offset, size);
		MoveFilePointer(offset);
		fwrite(data, size, 1, file);
	}
Exemple #13
0
NTSTATUS
RtlSelfRelativeAccessTokenToAccessToken(
    IN PACCESS_TOKEN_SELF_RELATIVE pRelative,
    IN ULONG ulRelativeSize,
    OUT PACCESS_TOKEN* ppToken
    )
{
    NTSTATUS status = STATUS_SUCCESS;
    ULONG ulOffset = 0;
    PBYTE pBuffer = (PBYTE) pRelative;
    PSID pSid = NULL;
    PSID_AND_ATTRIBUTES_SELF_RELATIVE pGroups = NULL;
    ULONG ulSize = 0;
    ULONG ulRealSize = 0;
    ULONG i = 0;
    TOKEN_USER User = {{0}};
    TOKEN_OWNER Owner = {0};
    TOKEN_PRIMARY_GROUP PrimaryGroup = {0};
    TOKEN_UNIX Unix = {0};
    PTOKEN_GROUPS pTokenGroups = NULL;
    PTOKEN_PRIVILEGES pTokenPrivileges = NULL;
    TOKEN_DEFAULT_DACL DefaultDacl = {0};

    status = CheckOffset(0, sizeof(*pRelative), ulRelativeSize);
    GOTO_CLEANUP_ON_STATUS(status);

    if (pRelative->Flags & ACCESS_TOKEN_FLAG_UNIX_PRESENT)
    {
        Unix.Uid = pRelative->Uid;
        Unix.Gid = pRelative->Gid;
        Unix.Umask = pRelative->Umask;
    }

    User.User.Attributes = pRelative->User.Attributes;
    ulOffset = pRelative->User.SidOffset;
    pSid = (PSID) (pBuffer + ulOffset);
    status = RtlValidateSelfRelativeSid(pSid, ulOffset, ulRelativeSize);
    GOTO_CLEANUP_ON_STATUS(status);
    
    User.User.Sid = pSid;

    ulOffset = pRelative->GroupsOffset;
    if (ulOffset)
    {
        status = LwRtlSafeMultiplyULONG(
            &ulSize,
            sizeof(SID_AND_ATTRIBUTES_SELF_RELATIVE),
            pRelative->GroupCount);
        GOTO_CLEANUP_ON_STATUS(status);

        status = LwRtlSafeMultiplyULONG(
            &ulRealSize,
            sizeof(SID_AND_ATTRIBUTES),
            pRelative->GroupCount);
        GOTO_CLEANUP_ON_STATUS(status);

        status = LwRtlSafeAddULONG(
            &ulRealSize,
            ulRealSize,
            sizeof(TOKEN_GROUPS));
        GOTO_CLEANUP_ON_STATUS(status);

        status = CheckOffset(ulOffset, ulSize, ulRelativeSize);
        GOTO_CLEANUP_ON_STATUS(status);

        pGroups = (PSID_AND_ATTRIBUTES_SELF_RELATIVE) (pBuffer + ulOffset);
        
        status = RTL_ALLOCATE(&pTokenGroups, TOKEN_GROUPS, ulRealSize);
        GOTO_CLEANUP_ON_STATUS(status);
        
        pTokenGroups->GroupCount = pRelative->GroupCount;

        for (i = 0; i < pRelative->GroupCount; i++)
        {
            pTokenGroups->Groups[i].Attributes = pGroups[i].Attributes;
            
            ulOffset = pGroups[i].SidOffset;
            pSid = (PSID) (pBuffer + ulOffset);
            status = RtlValidateSelfRelativeSid(pSid, ulOffset, ulRelativeSize);
            GOTO_CLEANUP_ON_STATUS(status);
            
            pTokenGroups->Groups[i].Sid = pSid;
        }
    }

    ulOffset = pRelative->PrivilegesOffset;
    if (ulOffset)
    {
        status = LwRtlSafeMultiplyULONG(
            &ulSize,
            sizeof(LUID_AND_ATTRIBUTES),
            pRelative->PrivilegeCount);
        GOTO_CLEANUP_ON_STATUS(status);

        status = LwRtlSafeMultiplyULONG(
            &ulRealSize,
            sizeof(LUID_AND_ATTRIBUTES),
            pRelative->PrivilegeCount);
        GOTO_CLEANUP_ON_STATUS(status);

        status = LwRtlSafeAddULONG(
            &ulRealSize,
            ulRealSize,
            sizeof(TOKEN_PRIVILEGES));
        GOTO_CLEANUP_ON_STATUS(status);

        status = CheckOffset(ulOffset, ulSize, ulRelativeSize);
        GOTO_CLEANUP_ON_STATUS(status);

        status = RTL_ALLOCATE(&pTokenPrivileges, TOKEN_PRIVILEGES, ulRealSize);
        GOTO_CLEANUP_ON_STATUS(status);

        pTokenPrivileges->PrivilegeCount = pRelative->PrivilegeCount;
        memcpy(pTokenPrivileges->Privileges,
               pBuffer + ulOffset,
               sizeof(LUID_AND_ATTRIBUTES) * pTokenPrivileges->PrivilegeCount);
        
    }

    ulOffset = pRelative->OwnerOffset;
    if (ulOffset)
    {
        pSid = (PSID) (pBuffer + ulOffset);
        status = RtlValidateSelfRelativeSid(pSid, ulOffset, ulRelativeSize);
        GOTO_CLEANUP_ON_STATUS(status);
    
        Owner.Owner = pSid;
    }

    ulOffset = pRelative->PrimaryGroupOffset;
    if (ulOffset)
    {
        pSid = (PSID) (pBuffer + ulOffset);
        status = RtlValidateSelfRelativeSid(pSid, ulOffset, ulRelativeSize);
        GOTO_CLEANUP_ON_STATUS(status);
        
        PrimaryGroup.PrimaryGroup = pSid;
    }

    status = RtlCreateAccessToken(
        ppToken,
        &User,
        pTokenGroups,
        pTokenPrivileges,
        &Owner,
        &PrimaryGroup,
        &DefaultDacl,
        pRelative->Flags & ACCESS_TOKEN_FLAG_UNIX_PRESENT ? &Unix : NULL);
    GOTO_CLEANUP_ON_STATUS(status);

cleanup:

    RTL_FREE(&pTokenGroups);

    if (!NT_SUCCESS(status))
    {
        *ppToken = NULL;
    }

    return status;
}