1 | /* $Id: ParallelPortImpl.cpp 69496 2017-10-28 14:55:58Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox COM class implementation
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2017 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #include "ParallelPortImpl.h"
|
---|
19 | #include "MachineImpl.h"
|
---|
20 | #include "VirtualBoxImpl.h"
|
---|
21 |
|
---|
22 | #include <iprt/string.h>
|
---|
23 | #include <iprt/cpp/utils.h>
|
---|
24 |
|
---|
25 | #include <VBox/settings.h>
|
---|
26 |
|
---|
27 | #include "AutoStateDep.h"
|
---|
28 | #include "AutoCaller.h"
|
---|
29 | #include "Logging.h"
|
---|
30 |
|
---|
31 | ////////////////////////////////////////////////////////////////////////////////
|
---|
32 | //
|
---|
33 | // ParallelPort private data definition
|
---|
34 | //
|
---|
35 | ////////////////////////////////////////////////////////////////////////////////
|
---|
36 |
|
---|
37 | struct ParallelPort::Data
|
---|
38 | {
|
---|
39 | Data()
|
---|
40 | : fModified(false),
|
---|
41 | pMachine(NULL)
|
---|
42 | { }
|
---|
43 |
|
---|
44 | bool fModified;
|
---|
45 |
|
---|
46 | Machine * const pMachine;
|
---|
47 | const ComObjPtr<ParallelPort> pPeer;
|
---|
48 |
|
---|
49 | Backupable<settings::ParallelPort> bd;
|
---|
50 | };
|
---|
51 |
|
---|
52 | // constructor / destructor
|
---|
53 | /////////////////////////////////////////////////////////////////////////////
|
---|
54 | DEFINE_EMPTY_CTOR_DTOR(ParallelPort)
|
---|
55 |
|
---|
56 | HRESULT ParallelPort::FinalConstruct()
|
---|
57 | {
|
---|
58 | return BaseFinalConstruct();
|
---|
59 | }
|
---|
60 |
|
---|
61 | void ParallelPort::FinalRelease()
|
---|
62 | {
|
---|
63 | uninit();
|
---|
64 | BaseFinalRelease();
|
---|
65 | }
|
---|
66 |
|
---|
67 | // public initializer/uninitializer for internal purposes only
|
---|
68 | /////////////////////////////////////////////////////////////////////////////
|
---|
69 |
|
---|
70 | /**
|
---|
71 | * Initializes the Parallel Port object.
|
---|
72 | *
|
---|
73 | * @param aParent Handle of the parent object.
|
---|
74 | * @param aSlot Slotnumber this parallel port is plugged into.
|
---|
75 | */
|
---|
76 | HRESULT ParallelPort::init(Machine *aParent, ULONG aSlot)
|
---|
77 | {
|
---|
78 | LogFlowThisFunc(("aParent=%p, aSlot=%d\n", aParent, aSlot));
|
---|
79 |
|
---|
80 | ComAssertRet(aParent, E_INVALIDARG);
|
---|
81 |
|
---|
82 | /* Enclose the state transition NotReady->InInit->Ready */
|
---|
83 | AutoInitSpan autoInitSpan(this);
|
---|
84 | AssertReturn(autoInitSpan.isOk(), E_FAIL);
|
---|
85 |
|
---|
86 | m = new Data;
|
---|
87 |
|
---|
88 | unconst(m->pMachine) = aParent;
|
---|
89 | /* m->pPeer is left null */
|
---|
90 |
|
---|
91 | m->bd.allocate();
|
---|
92 |
|
---|
93 | /* initialize data */
|
---|
94 | m->bd->ulSlot = aSlot;
|
---|
95 |
|
---|
96 | /* Confirm a successful initialization */
|
---|
97 | autoInitSpan.setSucceeded();
|
---|
98 |
|
---|
99 | return S_OK;
|
---|
100 | }
|
---|
101 |
|
---|
102 | /**
|
---|
103 | * Initializes the Parallel Port object given another serial port object
|
---|
104 | * (a kind of copy constructor). This object shares data with
|
---|
105 | * the object passed as an argument.
|
---|
106 | *
|
---|
107 | * @note This object must be destroyed before the original object
|
---|
108 | * it shares data with is destroyed.
|
---|
109 | *
|
---|
110 | * @note Locks @a aThat object for reading.
|
---|
111 | */
|
---|
112 | HRESULT ParallelPort::init(Machine *aParent, ParallelPort *aThat)
|
---|
113 | {
|
---|
114 | LogFlowThisFunc(("aParent=%p, aThat=%p\n", aParent, aThat));
|
---|
115 |
|
---|
116 | ComAssertRet(aParent && aThat, E_INVALIDARG);
|
---|
117 |
|
---|
118 | /* Enclose the state transition NotReady->InInit->Ready */
|
---|
119 | AutoInitSpan autoInitSpan(this);
|
---|
120 | AssertReturn(autoInitSpan.isOk(), E_FAIL);
|
---|
121 |
|
---|
122 | m = new Data;
|
---|
123 |
|
---|
124 | unconst(m->pMachine) = aParent;
|
---|
125 | unconst(m->pPeer) = aThat;
|
---|
126 |
|
---|
127 | AutoCaller thatCaller(aThat);
|
---|
128 | AssertComRCReturnRC(thatCaller.rc());
|
---|
129 |
|
---|
130 | AutoReadLock thatLock(aThat COMMA_LOCKVAL_SRC_POS);
|
---|
131 | m->bd.share(aThat->m->bd);
|
---|
132 |
|
---|
133 | /* Confirm a successful initialization */
|
---|
134 | autoInitSpan.setSucceeded();
|
---|
135 |
|
---|
136 | return S_OK;
|
---|
137 | }
|
---|
138 |
|
---|
139 | /**
|
---|
140 | * Initializes the guest object given another guest object
|
---|
141 | * (a kind of copy constructor). This object makes a private copy of data
|
---|
142 | * of the original object passed as an argument.
|
---|
143 | *
|
---|
144 | * @note Locks @a aThat object for reading.
|
---|
145 | */
|
---|
146 | HRESULT ParallelPort::initCopy(Machine *aParent, ParallelPort *aThat)
|
---|
147 | {
|
---|
148 | LogFlowThisFunc(("aParent=%p, aThat=%p\n", aParent, aThat));
|
---|
149 |
|
---|
150 | ComAssertRet(aParent && aThat, E_INVALIDARG);
|
---|
151 |
|
---|
152 | /* Enclose the state transition NotReady->InInit->Ready */
|
---|
153 | AutoInitSpan autoInitSpan(this);
|
---|
154 | AssertReturn(autoInitSpan.isOk(), E_FAIL);
|
---|
155 |
|
---|
156 | m = new Data;
|
---|
157 |
|
---|
158 | unconst(m->pMachine) = aParent;
|
---|
159 | /* m->pPeer is left null */
|
---|
160 |
|
---|
161 | AutoCaller thatCaller(aThat);
|
---|
162 | AssertComRCReturnRC(thatCaller.rc());
|
---|
163 |
|
---|
164 | AutoReadLock thatLock(aThat COMMA_LOCKVAL_SRC_POS);
|
---|
165 | m->bd.attachCopy(aThat->m->bd);
|
---|
166 |
|
---|
167 | /* Confirm a successful initialization */
|
---|
168 | autoInitSpan.setSucceeded();
|
---|
169 |
|
---|
170 | return S_OK;
|
---|
171 | }
|
---|
172 |
|
---|
173 | /**
|
---|
174 | * Uninitializes the instance and sets the ready flag to FALSE.
|
---|
175 | * Called either from FinalRelease() or by the parent when it gets destroyed.
|
---|
176 | */
|
---|
177 | void ParallelPort::uninit()
|
---|
178 | {
|
---|
179 | LogFlowThisFunc(("\n"));
|
---|
180 |
|
---|
181 | /* Enclose the state transition Ready->InUninit->NotReady */
|
---|
182 | AutoUninitSpan autoUninitSpan(this);
|
---|
183 | if (autoUninitSpan.uninitDone())
|
---|
184 | return;
|
---|
185 |
|
---|
186 | m->bd.free();
|
---|
187 |
|
---|
188 | unconst(m->pPeer) = NULL;
|
---|
189 | unconst(m->pMachine) = NULL;
|
---|
190 |
|
---|
191 | delete m;
|
---|
192 | m = NULL;
|
---|
193 | }
|
---|
194 |
|
---|
195 | // IParallelPort properties
|
---|
196 | /////////////////////////////////////////////////////////////////////////////
|
---|
197 |
|
---|
198 | HRESULT ParallelPort::getEnabled(BOOL *aEnabled)
|
---|
199 | {
|
---|
200 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
201 |
|
---|
202 | *aEnabled = m->bd->fEnabled;
|
---|
203 |
|
---|
204 | return S_OK;
|
---|
205 | }
|
---|
206 |
|
---|
207 | HRESULT ParallelPort::setEnabled(BOOL aEnabled)
|
---|
208 | {
|
---|
209 | LogFlowThisFunc(("aEnabled=%RTbool\n", aEnabled));
|
---|
210 | /* the machine needs to be mutable */
|
---|
211 | AutoMutableStateDependency adep(m->pMachine);
|
---|
212 | if (FAILED(adep.rc())) return adep.rc();
|
---|
213 |
|
---|
214 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
215 |
|
---|
216 | if (m->bd->fEnabled != RT_BOOL(aEnabled))
|
---|
217 | {
|
---|
218 | m->bd.backup();
|
---|
219 | m->bd->fEnabled = RT_BOOL(aEnabled);
|
---|
220 |
|
---|
221 | m->fModified = true;
|
---|
222 | // leave the lock before informing callbacks
|
---|
223 | alock.release();
|
---|
224 |
|
---|
225 | AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);
|
---|
226 | m->pMachine->i_setModified(Machine::IsModified_ParallelPorts);
|
---|
227 | mlock.release();
|
---|
228 |
|
---|
229 | m->pMachine->i_onParallelPortChange(this);
|
---|
230 | }
|
---|
231 |
|
---|
232 | return S_OK;
|
---|
233 | }
|
---|
234 |
|
---|
235 | HRESULT ParallelPort::getSlot(ULONG *aSlot)
|
---|
236 | {
|
---|
237 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
238 |
|
---|
239 | *aSlot = m->bd->ulSlot;
|
---|
240 |
|
---|
241 | return S_OK;
|
---|
242 | }
|
---|
243 |
|
---|
244 | HRESULT ParallelPort::getIRQ(ULONG *aIRQ)
|
---|
245 | {
|
---|
246 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
247 |
|
---|
248 | *aIRQ = m->bd->ulIRQ;
|
---|
249 |
|
---|
250 | return S_OK;
|
---|
251 | }
|
---|
252 |
|
---|
253 | HRESULT ParallelPort::setIRQ(ULONG aIRQ)
|
---|
254 | {
|
---|
255 | /* check IRQ limits
|
---|
256 | * (when changing this, make sure it corresponds to XML schema */
|
---|
257 | if (aIRQ > 255)
|
---|
258 | return setError(E_INVALIDARG,
|
---|
259 | tr("Invalid IRQ number of the parallel port %d: %lu (must be in range [0, %lu])"),
|
---|
260 | m->bd->ulSlot, aIRQ, 255);
|
---|
261 |
|
---|
262 | /* the machine needs to be mutable */
|
---|
263 | AutoMutableStateDependency adep(m->pMachine);
|
---|
264 | if (FAILED(adep.rc())) return adep.rc();
|
---|
265 |
|
---|
266 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
267 |
|
---|
268 | if (m->bd->ulIRQ != aIRQ)
|
---|
269 | {
|
---|
270 | m->bd.backup();
|
---|
271 | m->bd->ulIRQ = aIRQ;
|
---|
272 |
|
---|
273 | m->fModified = true;
|
---|
274 | // leave the lock before informing callbacks
|
---|
275 | alock.release();
|
---|
276 |
|
---|
277 | AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);
|
---|
278 | m->pMachine->i_setModified(Machine::IsModified_ParallelPorts);
|
---|
279 | mlock.release();
|
---|
280 |
|
---|
281 | m->pMachine->i_onParallelPortChange(this);
|
---|
282 | }
|
---|
283 |
|
---|
284 | return S_OK;
|
---|
285 | }
|
---|
286 |
|
---|
287 | HRESULT ParallelPort::getIOBase(ULONG *aIOBase)
|
---|
288 | {
|
---|
289 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
290 |
|
---|
291 | *aIOBase = m->bd->ulIOBase;
|
---|
292 |
|
---|
293 | return S_OK;
|
---|
294 | }
|
---|
295 |
|
---|
296 | HRESULT ParallelPort::setIOBase(ULONG aIOBase)
|
---|
297 | {
|
---|
298 | /* check IOBase limits
|
---|
299 | * (when changing this, make sure it corresponds to XML schema */
|
---|
300 | if (aIOBase > 0xFFFF)
|
---|
301 | return setError(E_INVALIDARG,
|
---|
302 | tr("Invalid I/O port base address of the parallel port %d: %lu (must be in range [0, 0x%X])"),
|
---|
303 | m->bd->ulSlot, aIOBase, 0, 0xFFFF);
|
---|
304 |
|
---|
305 | /* the machine needs to be mutable */
|
---|
306 | AutoMutableStateDependency adep(m->pMachine);
|
---|
307 | if (FAILED(adep.rc())) return adep.rc();
|
---|
308 |
|
---|
309 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
310 |
|
---|
311 | if (m->bd->ulIOBase != aIOBase)
|
---|
312 | {
|
---|
313 | m->bd.backup();
|
---|
314 | m->bd->ulIOBase = aIOBase;
|
---|
315 |
|
---|
316 | m->fModified = true;
|
---|
317 | // leave the lock before informing callbacks
|
---|
318 | alock.release();
|
---|
319 |
|
---|
320 | AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);
|
---|
321 | m->pMachine->i_setModified(Machine::IsModified_ParallelPorts);
|
---|
322 | mlock.release();
|
---|
323 |
|
---|
324 | m->pMachine->i_onParallelPortChange(this);
|
---|
325 | }
|
---|
326 |
|
---|
327 | return S_OK;
|
---|
328 | }
|
---|
329 |
|
---|
330 |
|
---|
331 | HRESULT ParallelPort::getPath(com::Utf8Str &aPath)
|
---|
332 | {
|
---|
333 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
334 | aPath = m->bd->strPath;
|
---|
335 | return S_OK;
|
---|
336 | }
|
---|
337 |
|
---|
338 |
|
---|
339 | HRESULT ParallelPort::setPath(const com::Utf8Str &aPath)
|
---|
340 | {
|
---|
341 | /* the machine needs to be mutable */
|
---|
342 | AutoMutableOrSavedStateDependency adep(m->pMachine);
|
---|
343 | if (FAILED(adep.rc())) return adep.rc();
|
---|
344 |
|
---|
345 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
346 |
|
---|
347 | if (aPath != m->bd->strPath)
|
---|
348 | {
|
---|
349 | m->bd.backup();
|
---|
350 | m->bd->strPath = aPath;
|
---|
351 |
|
---|
352 | m->fModified = true;
|
---|
353 |
|
---|
354 | // leave the lock before informing callbacks
|
---|
355 | alock.release();
|
---|
356 |
|
---|
357 | AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);
|
---|
358 | m->pMachine->i_setModified(Machine::IsModified_ParallelPorts);
|
---|
359 | mlock.release();
|
---|
360 |
|
---|
361 | return m->pMachine->i_onParallelPortChange(this);
|
---|
362 | }
|
---|
363 |
|
---|
364 | return S_OK;
|
---|
365 | }
|
---|
366 |
|
---|
367 | // public methods only for internal purposes
|
---|
368 | ////////////////////////////////////////////////////////////////////////////////
|
---|
369 |
|
---|
370 | /**
|
---|
371 | * Loads settings from the given port node.
|
---|
372 | * May be called once right after this object creation.
|
---|
373 | *
|
---|
374 | * @param data Configuration settings.
|
---|
375 | *
|
---|
376 | * @note Locks this object for writing.
|
---|
377 | */
|
---|
378 | HRESULT ParallelPort::i_loadSettings(const settings::ParallelPort &data)
|
---|
379 | {
|
---|
380 | AutoCaller autoCaller(this);
|
---|
381 | AssertComRCReturnRC(autoCaller.rc());
|
---|
382 |
|
---|
383 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
384 |
|
---|
385 | // simply copy
|
---|
386 | *m->bd.data() = data;
|
---|
387 |
|
---|
388 | return S_OK;
|
---|
389 | }
|
---|
390 |
|
---|
391 | /**
|
---|
392 | * Saves settings to the given port node.
|
---|
393 | *
|
---|
394 | * Note that the given Port node is completely empty on input.
|
---|
395 | *
|
---|
396 | * @param data Configuration settings.
|
---|
397 | *
|
---|
398 | * @note Locks this object for reading.
|
---|
399 | */
|
---|
400 | HRESULT ParallelPort::i_saveSettings(settings::ParallelPort &data)
|
---|
401 | {
|
---|
402 | AutoCaller autoCaller(this);
|
---|
403 | AssertComRCReturnRC(autoCaller.rc());
|
---|
404 |
|
---|
405 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
406 |
|
---|
407 | // simply copy
|
---|
408 | data = *m->bd.data();
|
---|
409 |
|
---|
410 | return S_OK;
|
---|
411 | }
|
---|
412 |
|
---|
413 | /**
|
---|
414 | * Returns true if any setter method has modified settings of this instance.
|
---|
415 | * @return
|
---|
416 | */
|
---|
417 | bool ParallelPort::i_isModified()
|
---|
418 | {
|
---|
419 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
420 | return m->fModified;
|
---|
421 | }
|
---|
422 |
|
---|
423 | /**
|
---|
424 | * @note Locks this object for writing.
|
---|
425 | */
|
---|
426 | void ParallelPort::i_rollback()
|
---|
427 | {
|
---|
428 | /* sanity */
|
---|
429 | AutoCaller autoCaller(this);
|
---|
430 | AssertComRCReturnVoid(autoCaller.rc());
|
---|
431 |
|
---|
432 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
433 |
|
---|
434 | m->bd.rollback();
|
---|
435 | }
|
---|
436 |
|
---|
437 | /**
|
---|
438 | * @note Locks this object for writing, together with the peer object (also
|
---|
439 | * for writing) if there is one.
|
---|
440 | */
|
---|
441 | void ParallelPort::i_commit()
|
---|
442 | {
|
---|
443 | /* sanity */
|
---|
444 | AutoCaller autoCaller(this);
|
---|
445 | AssertComRCReturnVoid(autoCaller.rc());
|
---|
446 |
|
---|
447 | /* sanity too */
|
---|
448 | AutoCaller peerCaller(m->pPeer);
|
---|
449 | AssertComRCReturnVoid(peerCaller.rc());
|
---|
450 |
|
---|
451 | /* lock both for writing since we modify both (m->pPeer is "master" so locked
|
---|
452 | * first) */
|
---|
453 | AutoMultiWriteLock2 alock(m->pPeer, this COMMA_LOCKVAL_SRC_POS);
|
---|
454 |
|
---|
455 | if (m->bd.isBackedUp())
|
---|
456 | {
|
---|
457 | m->bd.commit();
|
---|
458 | if (m->pPeer)
|
---|
459 | {
|
---|
460 | /* attach new data to the peer and reshare it */
|
---|
461 | m->pPeer->m->bd.attach(m->bd);
|
---|
462 | }
|
---|
463 | }
|
---|
464 | }
|
---|
465 |
|
---|
466 | /**
|
---|
467 | * @note Locks this object for writing, together with the peer object
|
---|
468 | * represented by @a aThat (locked for reading).
|
---|
469 | */
|
---|
470 | void ParallelPort::i_copyFrom(ParallelPort *aThat)
|
---|
471 | {
|
---|
472 | AssertReturnVoid(aThat != NULL);
|
---|
473 |
|
---|
474 | /* sanity */
|
---|
475 | AutoCaller autoCaller(this);
|
---|
476 | AssertComRCReturnVoid(autoCaller.rc());
|
---|
477 |
|
---|
478 | /* sanity too */
|
---|
479 | AutoCaller thatCaller(aThat);
|
---|
480 | AssertComRCReturnVoid(thatCaller.rc());
|
---|
481 |
|
---|
482 | /* peer is not modified, lock it for reading (aThat is "master" so locked
|
---|
483 | * first) */
|
---|
484 | AutoReadLock rl(aThat COMMA_LOCKVAL_SRC_POS);
|
---|
485 | AutoWriteLock wl(this COMMA_LOCKVAL_SRC_POS);
|
---|
486 |
|
---|
487 | /* this will back up current data */
|
---|
488 | m->bd.assignCopy(aThat->m->bd);
|
---|
489 | }
|
---|
490 |
|
---|
491 | /**
|
---|
492 | * Applies the defaults for this parallel port.
|
---|
493 | *
|
---|
494 | * @note This method currently assumes that the object is in the state after
|
---|
495 | * calling init(), it does not set defaults from an arbitrary state.
|
---|
496 | */
|
---|
497 | void ParallelPort::i_applyDefaults()
|
---|
498 | {
|
---|
499 | /* sanity */
|
---|
500 | AutoCaller autoCaller(this);
|
---|
501 | AssertComRCReturnVoid(autoCaller.rc());
|
---|
502 |
|
---|
503 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
504 |
|
---|
505 | /* Set some more defaults based on the slot. */
|
---|
506 | switch (m->bd->ulSlot)
|
---|
507 | {
|
---|
508 | case 0:
|
---|
509 | {
|
---|
510 | m->bd->ulIOBase = 0x378;
|
---|
511 | m->bd->ulIRQ = 7;
|
---|
512 | break;
|
---|
513 | }
|
---|
514 | case 1:
|
---|
515 | {
|
---|
516 | m->bd->ulIOBase = 0x278;
|
---|
517 | m->bd->ulIRQ = 5;
|
---|
518 | break;
|
---|
519 | }
|
---|
520 | default:
|
---|
521 | AssertMsgFailed(("Parallel port slot %u exceeds limit\n", m->bd->ulSlot));
|
---|
522 | break;
|
---|
523 | }
|
---|
524 | }
|
---|
525 |
|
---|
526 | bool ParallelPort::i_hasDefaults()
|
---|
527 | {
|
---|
528 | /* sanity */
|
---|
529 | AutoCaller autoCaller(this);
|
---|
530 | AssertComRCReturn(autoCaller.rc(), true);
|
---|
531 |
|
---|
532 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
533 |
|
---|
534 | if (!m->bd->fEnabled)
|
---|
535 | {
|
---|
536 | /* Could be default, check the IO base and IRQ. */
|
---|
537 | switch (m->bd->ulSlot)
|
---|
538 | {
|
---|
539 | case 0:
|
---|
540 | if (m->bd->ulIOBase == 0x378 && m->bd->ulIRQ == 7)
|
---|
541 | return true;
|
---|
542 | break;
|
---|
543 | case 1:
|
---|
544 | if (m->bd->ulIOBase == 0x278 && m->bd->ulIRQ == 5)
|
---|
545 | return true;
|
---|
546 | break;
|
---|
547 | default:
|
---|
548 | AssertMsgFailed(("Parallel port slot %u exceeds limit\n", m->bd->ulSlot));
|
---|
549 | break;
|
---|
550 | }
|
---|
551 |
|
---|
552 | /* Detect old-style defaults (0x378, irq 4) in any slot, they are still
|
---|
553 | * in place for many VMs created by old VirtualBox versions. */
|
---|
554 | if (m->bd->ulIOBase == 0x378 && m->bd->ulIRQ == 4)
|
---|
555 | return true;
|
---|
556 | }
|
---|
557 |
|
---|
558 | return false;
|
---|
559 | }
|
---|
560 |
|
---|
561 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|