The Pedigree Project  0.1
AtaController.h
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 #ifndef ATA_CONTROLLER_H
21 #define ATA_CONTROLLER_H
22 
23 #include "modules/drivers/common/scsi/ScsiController.h"
24 #include "pedigree/kernel/Log.h"
25 #include "pedigree/kernel/machine/IrqHandler.h"
26 #include "pedigree/kernel/machine/types.h"
27 #include "pedigree/kernel/processor/state_forward.h"
28 #include "pedigree/kernel/processor/types.h"
29 #include "pedigree/kernel/utilities/RequestQueue.h"
30 #include "pedigree/kernel/utilities/String.h"
31 #include "pedigree/kernel/utilities/Vector.h"
32 
33 class Controller;
34 class IoBase;
35 
37 class AtaController : public ScsiController, public IrqHandler
38 {
39  public:
40  AtaController(Controller *pDev, int nController = 0)
41  : ScsiController(pDev), m_nController(nController)
42  {
43  setSpecificType(String("ata-controller"));
44 
45  // Ensure we have no stupid children lying around.
46  m_Children.clear();
47  }
48  virtual ~AtaController()
49  {
50  }
51 
52  virtual void getName(String &str) = 0;
53 
54  virtual bool compareRequests(
55  const RequestQueue::Request &a, const RequestQueue::Request &b);
56 
57  // IRQ handler callback.
58  virtual bool irq(irq_id_t number, InterruptState &state)
59  {
60  NOTICE("AtaController: irq" << Dec << number << Hex << " ignored");
61  return false;
62  }
63 
64  IoBase *m_pCommandRegs;
65  IoBase *m_pControlRegs;
66 
67  private:
69  void operator=(const AtaController &);
70 
71  protected:
72  int m_nController;
73 
74  virtual size_t getNumUnits()
75  {
76  return getNumChildren();
77  }
78 };
79 
80 #endif
size_t getNumChildren()
Definition: Device.cc:137
Definition: String.h:49
Abstrace base class for hardware I/O capabilities.
Definition: IoBase.h:31
virtual void setSpecificType(String str)
Definition: Device.h:174
#define NOTICE(text)
Definition: Log.h:74
virtual bool compareRequests(const RequestQueue::Request &a, const RequestQueue::Request &b)
virtual void getName(String &str)=0
Definition: Log.h:136
Definition: Log.h:138
void clear(bool freeMem=false)
Definition: Vector.h:337
Vector< Device * > m_Children
Definition: Device.h:364
virtual bool irq(irq_id_t number, InterruptState &state)
Definition: AtaController.h:58