source: sbliveos2/trunk/drv16/init.cpp@ 151

Last change on this file since 151 was 151, checked in by sandervl, 25 years ago

update

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.5 KB
Line 
1/* $Id: init.cpp 151 2000-05-28 16:50:46Z sandervl $ */
2
3/* SCCSID = %W% %E% */
4/****************************************************************************
5 * *
6 * Copyright (c) IBM Corporation 1994 - 1997. *
7 * *
8 * The following IBM OS/2 source code is provided to you solely for the *
9 * the purpose of assisting you in your development of OS/2 device drivers. *
10 * You may use this code in accordance with the IBM License Agreement *
11 * provided in the IBM Device Driver Source Kit for OS/2. *
12 * *
13 ****************************************************************************/
14/**@internal %W%
15 * Top level device driver initialization.
16 * @version %I%
17 * @context
18 * Physical DD initialization context: Ring3 with I/O privledge.
19 * Discarded after use.
20 * @notes
21 * Creates resource manager object and uses that RM object to figure out
22 * whether audio hardware is present. If present, RM provides IO resources
23 * to operate hardware. This modules uses that information to create
24 * Audio HW objects and other global data structures.
25 * @history
26 */
27
28#pragma code_seg ("_inittext");
29////#pragma data_seg ("_initdata","endds");
30
31extern "C" { // 16-bit header files are not C++ aware
32#define INCL_NOPMAPI
33#define INCL_DOSMISC
34#include <os2.h>
35#include <audio.h>
36#include <os2mixer.h>
37}
38
39#include <ctype.h>
40#include <string.h>
41#include <devhelp.h>
42#include "strategy.h" // OS/2 DD strategy interface
43#include "header.h" // Device driver header
44#include "parse.h" // Parses DEVICE= command line
45#include "malloc.h" // Heap memory used by this driver
46#include "mpu401.hpp" // Object definition
47#include "wavehw.hpp" // Object definition
48#include "irq.hpp" // Object definition
49#include "timer.hpp" // Object definition
50#include "stream.hpp" // pStreamList
51#include "rm.hpp" // Object definition
52#include "end.h" // end_of_data, end_of_text()
53#include "sizedefs.h" // HEAP_SIZE
54#include "idc_vdd.h" // VDD interface and Data Structs
55#include <include.h> // Pragmas and more.
56#include <sbversion.h>
57
58#ifndef PCI_VENDOR_ID_CREATIVE
59#define PCI_VENDOR_ID_CREATIVE 0x1102UL
60#endif
61
62#ifndef PCI_DEVICE_ID_CREATIVE_EMU10K1
63#define PCI_DEVICE_ID_CREATIVE_EMU10K1 0x0002UL
64#endif
65#define PCI_ID ((PCI_DEVICE_ID_CREATIVE_EMU10K1<<16UL)|PCI_VENDOR_ID_CREATIVE)
66
67// Default MIDI timer interval, milliseconds.
68static USHORT MIDI_TimerInterval = 10;
69
70static char szSBLive[] = "SoundBlaster Live! MMPM/2 Audio Driver v"SBLIVE_VERSION;
71static char szCopyRight[] = "Copyright 2000 Sander van Leeuwen (sandervl@xs4all.nl)";
72static char NEWLINE[] = "\r\n";
73static char szSBLiveNotFound[] = "SB Live! hardware not detected!";
74static char szAltF1[] = "Reboot, press Alt-F1 during OS/2 startup and select Enable Hardware Detection";
75
76//
77// ASCII Z-String used to register for PDD-VDD IDC must
78// Name is copied from header at runtime.
79//
80char szPddName [9] = {0};
81
82ResourceManager* pRM = 0; // Resource manager object.
83
84//
85// Strategy Init
86//
87void StrategyInit(PREQPACKET prp)
88{
89 Device_Help = (PFN) prp->s.init_in.ulDevHlp;
90 prp->s.init_out.usCodeEnd = 0;
91 prp->s.init_out.usDataEnd = 0;
92 prp->usStatus = RPDONE | RPERR | RPGENFAIL;
93
94 /* Initialize Heap. */
95 unsigned uInitSize; // Actual size of Heap following initialization.
96 uInitSize = HeapInit( HEAP_SIZE );
97 if ((HEAP_SIZE-uInitSize) > 64) { // Should get size of request, less some overhead.
98 // ### pError->vLog( HeapInitFailure ); //### Error log 'pError' not yet created.
99 return;
100 }
101 /* Heap initialized. */
102
103 // Initialize global lists.
104 pAudioHWList = new QUEUEHEAD;
105 pStreamList = new QUEUEHEAD;
106 pTimerList = new QUEUEHEAD;
107
108 // Fetch command line parameters.
109 if (!GetParms(prp->s.init_in.szArgs)) {
110 return;
111 }
112
113 // Now that we've grabbed our cmd line options,
114 // we can start processing stuff that depends on those switches.
115
116 if (fInt3BeforeInit) int3();
117
118 // If we got a /V (verbose) flag on the DEVICE= command, route messages
119 // to the display.
120 if (fVerbose) {
121 USHORT result;
122
123 DosWrite(1, (VOID FAR*)NEWLINE, sizeof(NEWLINE)-1, &result);
124 DosWrite(1, (VOID FAR*)szSBLive, strlen(szSBLive), &result);
125 DosWrite(1, (VOID FAR*)NEWLINE, sizeof(NEWLINE)-1, &result);
126
127 DosWrite(1, (VOID FAR*)szCopyRight, sizeof(szCopyRight), &result);
128 DosWrite(1, (VOID FAR*)NEWLINE, sizeof(NEWLINE)-1, &result);
129 DosWrite(1, (VOID FAR*)NEWLINE, sizeof(NEWLINE)-1, &result);
130 }
131
132 if (szCL_DevName[0] != ' ') // Was a valid device name specified?
133 memcpy(phdr->abName,szCL_DevName,8); // yes, copy it to the dev header
134
135 pRM = new ResourceManager(PCI_ID); // Create the RM object.
136 if (! pRM) {
137 return;
138 }
139 else if (pRM->getState() != rmDriverCreated) {
140 return;
141 }
142
143 //SvL: Check if SB Live hardware has been detected by the resource manager
144 // If not, tell user to reboot, press alt-f1 and enable hardware detection
145 if(!pRM->bIsDevDetected(PCI_ID, SEARCH_ID_DEVICEID, TRUE)) {
146 USHORT result;
147
148 DosWrite(1, (VOID FAR*)szSBLiveNotFound, strlen(szSBLiveNotFound), &result);
149 DosWrite(1, (VOID FAR*)NEWLINE, sizeof(NEWLINE)-1, &result);
150 DosWrite(1, (VOID FAR*)szAltF1, sizeof(szAltF1), &result);
151 DosWrite(1, (VOID FAR*)NEWLINE, sizeof(NEWLINE)-1, &result);
152 return;
153 }
154
155 // Build the MPU401 object only if we got a good 2115 init.
156 // First create a timer, then the HW object.
157 TIMER* pMPUTimer =
158 new TIMER(NULL, MIDI_TimerInterval, STREAM_MPU401_PLAY );
159 if (pMPUTimer->eState() != TIMER_Disabled)
160 new MPU_401(pMPUTimer);
161
162 SetHardwareType(AUDIOHW_MPU401_PLAY, MIDI, OPERATION_PLAY, 0);
163 SetHardwareType(AUDIOHW_MPU401_PLAY, DATATYPE_MIDI, OPERATION_PLAY, 0);
164 SetHardwareType(AUDIOHW_MPU401_PLAY, 0, OPERATION_PLAY, 0); //### Must be fixed.
165
166 // Build the Wave Playback Hardware object
167 new WAVEPLAY();
168 new WAVEREC();
169
170#if 0
171 // fill in the ADAPTERINFO
172 codec_info.ulNumPorts = NUMIORANGES;
173 codec_info.Range[0].ulPort = pResourcesWSS->uIOBase[0];
174 codec_info.Range[0].ulRange = pResourcesWSS->uIOLength[0];
175 codec_info.Range[1].ulPort = pResourcesWSS->uIOBase[1];
176 codec_info.Range[1].ulRange = pResourcesWSS->uIOLength[1];
177 codec_info.Range[2].ulPort = pResourcesWSS->uIOBase[2];
178 codec_info.Range[2].ulRange = pResourcesWSS->uIOLength[2];
179 codec_info.Range[3].ulPort = pResourcesICS->uIOBase[0];
180 codec_info.Range[3].ulRange = pResourcesICS->uIOLength[0];
181
182 // set up the addressing to the codec data for the vdd
183 pfcodec_info = (ADAPTERINFO __far *)&codec_info;
184 DevHelp_VirtToLin (SELECTOROF(pfcodec_info), (ULONG)(OFFSETOF(pfcodec_info)),
185 (PLIN)&pLincodec);
186
187 // copy the pdd name out of the header.
188 for (int i = 0; i < sizeof(szPddName)-1 ; i++) {
189 if (phdr->abName[i] <= ' ')
190 break;
191 szPddName[i] = phdr->abName[i];
192 }
193 // register the VDD IDC entry point..
194 DevHelp_RegisterPDD ((NPSZ)szPddName, (PFN)IDCEntry_VDD);
195#endif
196
197 prp->usStatus = RPDONE;
198 prp->s.init_out.usCodeEnd = (USHORT) &end_of_text;
199 prp->s.init_out.usDataEnd = (USHORT) &end_of_heap;
200}
Note: See TracBrowser for help on using the repository browser.