Source code of Windows XP (NT5)
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.

101 lines
2.8 KiB

  1. /****************************************************************************
  2. *
  3. * capdriv.c
  4. *
  5. * Smartdrv control.
  6. *
  7. * Microsoft Video for Windows Sample Capture Class
  8. *
  9. * Copyright (c) 1992, 1993 Microsoft Corporation. All Rights Reserved.
  10. *
  11. * You have a royalty-free right to use, modify, reproduce and
  12. * distribute the Sample Files (and/or any modified version) in
  13. * any way you find useful, provided that you agree that
  14. * Microsoft has no warranty obligations or liability for any
  15. * Sample Application Files which are modified.
  16. *
  17. ***************************************************************************/
  18. #include <windows.h>
  19. #include <windowsx.h>
  20. #pragma optimize ("", off)
  21. // SD_CACHE_DRIVE:
  22. // FUNCTION:
  23. // Enables and disables read or write caching for a particular
  24. // drive unit. Returns the cache state of the drive in DL. Get
  25. // takes no action, but simply returns cache state for drive unit
  26. // in DL.
  27. //
  28. // INPUT:
  29. // AX=MULT_SMARTDRV (4A10h)
  30. // BX=SD_CACHE_DRIVE (3)
  31. // DL=CACHE_DRIVE_<get,read|write enable|disable>
  32. // BP=unit number of drive
  33. // OUTPUT:
  34. // DL=cache state of unit:
  35. // Bit 7 set -> no caching enabled for this unit
  36. // Bit 7 not set -> read caching enabled for this unit
  37. // Bit 6 set -> write caching not enabled for this unit
  38. // Bit 6 not set -> write caching enabled for this unit
  39. // -1 -> not a cachable drive
  40. // USES:
  41. // ALL except DS,ES
  42. //
  43. #define MULT_SMARTDRV 0x4a10
  44. #define SD_CACHE_DRIVE 3
  45. #define CACHE_DRIVE_GET 0
  46. #define CACHE_DRIVE_READ_ENABLE 1
  47. #define CACHE_DRIVE_READ_DISABLE 2
  48. #define CACHE_DRIVE_WRITE_ENABLE 3
  49. #define CACHE_DRIVE_WRITE_DISABLE 4
  50. #define F_WRITE_CACHE (1 << 7)
  51. #define F_READ_CACHE (1 << 6)
  52. WORD NEAR PASCAL SmartDrvCache(int iDrive, BYTE cmd)
  53. {
  54. WORD w;
  55. _asm {
  56. push bp
  57. mov ax, MULT_SMARTDRV
  58. mov bx, SD_CACHE_DRIVE
  59. mov dl, cmd
  60. mov bp, iDrive
  61. int 2fh
  62. mov al,dl
  63. xor ah,ah
  64. pop bp
  65. mov w,ax
  66. }
  67. return w;
  68. }
  69. WORD FAR PASCAL SmartDrv(char chDrive, WORD w)
  70. {
  71. WORD wCur;
  72. int iDrive;
  73. iDrive = (chDrive | 0x20) - 'a';
  74. wCur = SmartDrvCache(iDrive, CACHE_DRIVE_GET);
  75. if (w & F_WRITE_CACHE)
  76. SmartDrvCache(iDrive, CACHE_DRIVE_WRITE_DISABLE);
  77. else
  78. SmartDrvCache(iDrive, CACHE_DRIVE_WRITE_ENABLE);
  79. if (w & F_READ_CACHE)
  80. SmartDrvCache(iDrive, CACHE_DRIVE_READ_DISABLE);
  81. else
  82. SmartDrvCache(iDrive, CACHE_DRIVE_READ_ENABLE);
  83. return wCur;
  84. }
  85. #pragma optimize ("", on)