ReactOS  0.4.14-dev-114-gc8cbd56
mpu401.h
Go to the documentation of this file.
1 /*
2  *
3  * COPYRIGHT: See COPYING in the top level directory
4  * PROJECT: ReactOS kernel
5  * FILE: services/dd/mpu401/mpu401.h
6  * PURPOSE: MPU-401 MIDI device driver header
7  * PROGRAMMER: Andrew Greenwood
8  * UPDATE HISTORY:
9  * Sept 26, 2003: Created
10  */
11 
12 #pragma once
13 
14 //#include <mmsystem.h>
15 //#include <mmddk.h>
16 //#include <winioctl.h>
17 #include "../../../dll/win32/mmdrv/mmdef.h"
18 
19 #define DEFAULT_PORT 0x330
20 #define DEFAULT_IRQ 9
21 
22 #define DEVICE_SUBKEY L"Devices"
23 #define PARMS_SUBKEY L"Parameters"
24 
25 #define REGISTRY_PORT L"Port"
26 
27 // At the moment, we just support a single device with fixed parameters:
28 #define MPU401_PORT DEFAULT_PORT
29 #define MPU401_IRQ DEFAULT_IRQ
30 
31 #define MPU401_TIMEOUT 10000
32 
33 /* OBSOLETE - see mmdef.h instead:
34 #define IOCTL_SOUND_BASE FILE_DEVICE_SOUND
35 // wave base 0
36 #define IOCTL_MIDI_BASE 0x0080
37 
38 #define IOCTL_MIDI_GET_CAPABILITIES CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIDI_BASE + 0x0001, METHOD_BUFFERED, FILE_READ_ACCESS)
39 #define IOCTL_MIDI_SET_STATE CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIDI_BASE + 0x0002, METHOD_BUFFERED, FILE_WRITE_ACCESS)
40 #define IOCTL_MIDI_GET_STATE CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIDI_BASE + 0x0003, METHOD_BUFFERED, FILE_WRITE_ACCESS)
41 #define IOCTL_MIDI_SET_VOLUME CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIDI_BASE + 0x0004, METHOD_BUFFERED, FILE_READ_ACCESS)
42 #define IOCTL_MIDI_GET_VOLUME CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIDI_BASE + 0x0005, METHOD_BUFFERED, FILE_READ_ACCESS)
43 #define IOCTL_MIDI_PLAY CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIDI_BASE + 0x0006, METHOD_BUFFERED, FILE_WRITE_ACCESS)
44 #define IOCTL_MIDI_RECORD CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIDI_BASE + 0x0007, METHOD_BUFFERED, FILE_WRITE_ACCESS)
45 #define IOCTL_MIDI_CACHE_PATCHES CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIDI_BASE + 0x0008, METHOD_BUFFERED, FILE_WRITE_ACCESS)
46 #define IOCTL_MIDI_CACHE_DRUM_PATCHES CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIDI_BASE + 0x0009, METHOD_BUFFERED, FILE_WRITE_ACCESS)
47 */
48 
49 // The MPU-401 has 2 ports, usually 0x330 and 0x331, which are known as
50 // "data" and "status/command", respectively. These macros deal with
51 // reading from and writing to these ports:
52 
53 #define MPU401_WRITE_DATA(bp, x) WRITE_PORT_UCHAR((PUCHAR) bp, x)
54 #define MPU401_READ_DATA(bp) READ_PORT_UCHAR((PUCHAR) bp)
55 #define MPU401_WRITE_COMMAND(bp, x) WRITE_PORT_UCHAR((PUCHAR) bp+1, x)
56 #define MPU401_READ_STATUS(bp) READ_PORT_UCHAR((PUCHAR) bp+1)
57 
58 
59 // Flow control
60 
61 #define MPU401_READY_TO_SEND(bp) \
62  MPU401_READ_STATUS(bp) & 0x80
63 
64 #define MPU401_READY_TO_RECEIVE(bp) \
65  MPU401_READ_STATUS(bp) & 0x40
66 
67 
68 #define MPU401_WRITE_BYTE(bp, x) \
69  if (WaitToSend(bp)) MPU401_WRITE_DATA(bp, x)
70 
71 #define MPU401_WRITE_MESSAGE(bp, status, da, db) \
72  MPU401_WRITE(bp, status); \
73  MPU401_WRITE(bp, da); \
74  MPU401_WRITE(bp, db)
75 
76 //#define MPU401_READ(bp)
77 // if (WaitToRead(bp)) ... ???
78 
79 /*
80  DEVICE_EXTENSION contains the settings for each individual device
81 */
82 
83 typedef struct _DEVICE_EXTENSION
84 {
89 // KDPC Dpc;
90 // KTIMER Timer;
91 // KEVENT Event;
92 // BOOLEAN BeepOn;
94 
95 /*
96  DEVICE_INSTANCE contains ???
97 */
98 
99 typedef struct _DEVICE_INSTANCE
100 {
101  // pPrevGDI
104 
105 /*
106  CONFIG contains device parameters (port/IRQ)
107  THIS STRUCTURE IS REDUNDANT
108 */
109 
110 //typedef struct _CONFIG
111 //{
112 // ULONG Port;
113 // ULONG IRQ;
114 //} CONFIG, *PCONFIG;
115 
116 /*
117  Some callback typedefs
118 */
119 
122 
123 
124 /*
125  Prototypes for functions in portio.c :
126 */
127 
128 BOOLEAN WaitToSend(ULONG BasePort);
129 BOOLEAN WaitToReceive(ULONG BasePort);
130 BOOLEAN InitUARTMode(ULONG BasePort);
131 
132 /*
133  Prototypes for functions in settings.c :
134 */
135 
138  IN PWSTR SubKey,
140  IN PVOID Context);
141 
147  IN PVOID Context,
149 
#define IN
Definition: typedefs.h:38
NTSTATUS NTAPI DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
Definition: battc.c:16
uint16_t * PWSTR
Definition: typedefs.h:54
BOOLEAN WaitToSend(ULONG BasePort)
Definition: portio.c:16
_In_ PCWSTR _In_z_ PCWSTR _In_ ULONG ValueType
Definition: rtlfuncs.h:4016
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI LoadSettings(IN PWSTR ValueName, IN ULONG ValueType, IN PVOID ValueData, IN ULONG ValueLength, IN PVOID Context, IN PVOID EntryContext)
Definition: settings.c:233
PUNICODE_STRING RegistryPath
Definition: mpu401.h:85
struct _DEVICE_INSTANCE DEVICE_INSTANCE
NTSTATUS REGISTRY_CALLBACK_ROUTINE(PWSTR RegistryPath, PVOID Context)
Definition: mpu401.h:120
_In_ PUNICODE_STRING ValueName
Definition: cmfuncs.h:264
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
PDRIVER_OBJECT DriverObject
Definition: mpu401.h:102
struct _DEVICE_INSTANCE * PDEVICE_INSTANCE
unsigned char BOOLEAN
_In_ PCWSTR _Inout_ _At_ QueryTable EntryContext
Definition: rtlfuncs.h:4004
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
REGISTRY_CALLBACK_ROUTINE * PREGISTRY_CALLBACK_ROUTINE
Definition: mpu401.h:121
BOOLEAN WaitToReceive(ULONG BasePort)
Definition: portio.c:40
PDRIVER_OBJECT DriverObject
Definition: mntmgr.h:16
_In_ GUID _In_ PVOID ValueData
Definition: hubbusif.h:311
_In_ GUID _In_ PVOID _In_ ULONG ValueLength
Definition: hubbusif.h:311
NTSTATUS NTAPI EnumDeviceKeys(IN PUNICODE_STRING RegistryPath, IN PWSTR SubKey, IN PREGISTRY_CALLBACK_ROUTINE Callback, IN PVOID Context)
Definition: settings.c:73
struct _DEVICE_EXTENSION DEVICE_EXTENSION
BOOLEAN InitUARTMode(ULONG BasePort)
Definition: portio.c:64
unsigned int ULONG
Definition: retypes.h:1
_In_ PUNICODE_STRING RegistryPath
Definition: wmip.h:27
struct _DEVICE_EXTENSION * PDEVICE_EXTENSION
LPFNPSPCALLBACK Callback
Definition: desk.c:111