The Pedigree Project  0.1
ScsiController.cc
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #include "ScsiController.h"
21 #include "ScsiDisk.h"
22 #include "pedigree/kernel/utilities/new"
23 
24 ScsiController::ScsiController(Controller *pDev)
25  : Controller(pDev), RequestQueue("ScsiController")
26 {
27  initialise();
28 }
29 
30 ScsiController::ScsiController() : RequestQueue("ScsiController")
31 {
32  // Start the RequestQueue
33  initialise();
34 }
35 
36 ScsiController::~ScsiController() = default;
37 
38 void ScsiController::searchDisks()
39 {
40  for (size_t i = 0; i < getNumUnits(); i++)
41  {
42  ScsiDisk *pDisk = new ScsiDisk();
43  if (pDisk->initialise(this, i))
44  addChild(pDisk);
45  else
46  delete pDisk;
47  }
48 }
49 
51  uint64_t p1, uint64_t p2, uint64_t p3, uint64_t p4, uint64_t p5,
52  uint64_t p6, uint64_t p7, uint64_t p8)
53 {
54  ScsiDisk *pDisk = reinterpret_cast<ScsiDisk *>(p2);
55  if (p1 == SCSI_REQUEST_READ)
56  return pDisk->doRead(p3);
57  else if (p1 == SCSI_REQUEST_WRITE)
58  return pDisk->doWrite(p3);
59  else if (p1 == SCSI_REQUEST_SYNC)
60  return pDisk->doSync(p3);
61  else
62  return 0;
63 }
virtual uint64_t executeRequest(uint64_t p1, uint64_t p2, uint64_t p3, uint64_t p4, uint64_t p5, uint64_t p6, uint64_t p7, uint64_t p8)
virtual uint64_t doRead(uint64_t location)
Definition: ScsiDisk.cc:448
bool initialise(class ScsiController *pController, size_t nUnit)
Definition: ScsiDisk.cc:78