Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.1 KiB

  1. // $Header: G:/SwDev/WDM/Video/bt848/rcs/Physaddr.h 1.3 1998/04/29 22:43:34 tomz Exp $
  2. #ifndef __PHYSADDR_H
  3. #define __PHYSADDR_H
  4. inline DWORD GetPhysAddr( DataBuf &buf )
  5. {
  6. ULONG len = 0;
  7. return StreamClassGetPhysicalAddress( buf.pSrb_->HwDeviceExtension, buf.pSrb_,
  8. buf.pData_, SRBDataBuffer, &len ).LowPart;
  9. }
  10. /* Function: IsSumAbovePage
  11. * Purpose: Sees if sum of 2 numbers is bigger then page
  12. * Input: first: DWORD
  13. * second: DWORD,
  14. * Output: bool
  15. */
  16. inline bool IsSumAbovePage( DWORD first, DWORD second )
  17. {
  18. return bool( BYTE_OFFSET( first ) + BYTE_OFFSET( second ) > ( PAGE_SIZE - 1 ) );
  19. // return bool( ( first & 0xFFF ) + ( second & 0xFFF ) > 0xFFF );
  20. }
  21. /* Function: Need2Split
  22. * Purpose: Sees if a scan line needs to be broken into 2 instructions
  23. * Input: dwAddr: DWORD, address
  24. * wCOunt: WORD, byte count
  25. * Output: bool
  26. */
  27. inline bool Need2Split( DataBuf &buf, WORD wCount )
  28. {
  29. DataBuf tmp = buf;
  30. tmp.pData_ += wCount;
  31. return bool( IsSumAbovePage( DWORD( buf.pData_ ), wCount ) &&
  32. ( GetPhysAddr( tmp ) - GetPhysAddr( buf ) != wCount ) );
  33. }
  34. #endif