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.

171 lines
4.4 KiB

  1. // Copyright (c) 1998 Microsoft Corporation
  2. //
  3. // Kernel mode DirectMusic DLS level 1 Software Synthesizer
  4. //
  5. //
  6. // All the GUIDS for all the miniports end up in this object.
  7. //
  8. #define PUT_GUIDS_HERE
  9. #define STR_MODULENAME "kmsynth: "
  10. #define MAX_MINIPORTS 1
  11. #include "common.h"
  12. #include "private.h"
  13. #if (DBG)
  14. #define SUCCEEDS(s) ASSERT(NT_SUCCESS(s))
  15. #else
  16. #define SUCCEEDS(s) (s)
  17. #endif
  18. NTSTATUS
  19. AddDevice
  20. (
  21. IN PVOID Context1, // Context for the class driver.
  22. IN PVOID Context2 // Context for the class driver.
  23. );
  24. NTSTATUS
  25. StartDevice
  26. (
  27. IN PVOID Context1, // Context for the class driver.
  28. IN PVOID Context2, // Context for the class driver.
  29. IN PRESOURCELIST ResourceList // List of hardware resources.
  30. );
  31. #pragma code_seg("PAGE")
  32. /*****************************************************************************
  33. * DriverEntry()
  34. *****************************************************************************
  35. * This function is called by the operating system when the driver is loaded.
  36. * All adapter drivers can use this code without change.
  37. */
  38. extern "C"
  39. NTSTATUS
  40. DriverEntry
  41. (
  42. IN PVOID Context1, // Context for the class driver.
  43. IN PVOID Context2 // Context for the class driver.
  44. )
  45. {
  46. PAGED_CODE();
  47. //
  48. // Tell the class driver to initialize the driver.
  49. //
  50. return InitializeAdapterDriver(Context1,Context2, AddDevice);
  51. }
  52. /*****************************************************************************
  53. * AddDevice()
  54. *****************************************************************************
  55. * This function is called by the operating system when the device is added.
  56. * All adapter drivers can use this code without change.
  57. */
  58. NTSTATUS
  59. AddDevice
  60. (
  61. IN PVOID Context1, // Context for the class driver.
  62. IN PVOID Context2 // Context for the class driver.
  63. )
  64. {
  65. PAGED_CODE();
  66. //
  67. // Tell the class driver to add the device.
  68. //
  69. return AddAdapterDevice(Context1,Context2, StartDevice,MAX_MINIPORTS);
  70. }
  71. /*****************************************************************************
  72. * StartDevice()
  73. *****************************************************************************
  74. * This function is called by the operating system when the device is started.
  75. * It is responsible for starting the miniports. This code is specific to
  76. * the adapter because it calls out miniports for functions that are specific
  77. * to the adapter.
  78. */
  79. NTSTATUS
  80. StartDevice
  81. (
  82. IN PVOID Context1, // Context for the class driver.
  83. IN PVOID Context2, // Context for the class driver.
  84. IN PRESOURCELIST ResourceList // List of hardware resources.
  85. )
  86. {
  87. PAGED_CODE();
  88. ASSERT(Context1);
  89. ASSERT(Context2);
  90. ASSERT(ResourceList);
  91. // We only care about having a dummy MIDI miniport
  92. //
  93. PPORT port;
  94. NTSTATUS nt = NewPort(&port, CLSID_PortSynthesizer);
  95. if (!NT_SUCCESS(nt))
  96. {
  97. return nt;
  98. }
  99. PUNKNOWN pPortInterface;
  100. nt = port->QueryInterface(IID_IPortSynthesizer, (LPVOID*)&pPortInterface);
  101. if (!NT_SUCCESS(nt))
  102. {
  103. port->Release();
  104. return nt;
  105. }
  106. PUNKNOWN miniport;
  107. nt = CreateMiniportDmSynth(&miniport, NULL, NonPagedPool);
  108. if (!NT_SUCCESS(nt))
  109. {
  110. pPortInterface->Release();
  111. port->Release();
  112. return nt;
  113. }
  114. nt = port->Init(Context1, Context2, miniport, NULL, ResourceList);
  115. if (!NT_SUCCESS(nt))
  116. {
  117. pPortInterface->Release();
  118. port->Release();
  119. miniport->Release();
  120. return nt;
  121. }
  122. nt = RegisterSubdevice(Context1, Context2, L"MSSWSynth", port);
  123. if (!NT_SUCCESS(nt))
  124. {
  125. pPortInterface->Release();
  126. port->Release();
  127. miniport->Release();
  128. return nt;
  129. }
  130. return nt;
  131. }
  132. #pragma code_seg()
  133. /*****************************************************************************
  134. * _purecall()
  135. *****************************************************************************
  136. * The C++ compiler loves me.
  137. * TODO: Figure out how to put this into portcls.sys
  138. */
  139. int __cdecl
  140. _purecall( void )
  141. {
  142. ASSERT( !"Pure virtual function called" );
  143. return 0;
  144. }