The Pedigree Project  0.1
PciAtaController.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 PCI_ATA_CONTROLLER_H
21 #define PCI_ATA_CONTROLLER_H
22 
23 #include "AtaController.h"
24 #include "pedigree/kernel/machine/types.h"
25 #include "pedigree/kernel/processor/state_forward.h"
26 #include "pedigree/kernel/processor/types.h"
27 #include "pedigree/kernel/utilities/StaticString.h"
28 #include "pedigree/kernel/utilities/String.h"
29 
30 class BusMasterIde;
31 class Controller;
32 class IoBase;
33 
34 #define ATA_CMD_READ 0
35 #define ATA_CMD_WRITE 1
36 
39 {
40  public:
41  PciAtaController(Controller *pDev, int nController = 0);
42  virtual ~PciAtaController();
43 
44  virtual void getName(String &str)
45  {
47  s.clear();
48  s += "pci-ata-";
49  s.append(m_nController);
50  str = String(static_cast<const char *>(s));
51  }
52 
53  virtual bool sendCommand(
54  size_t nUnit, uintptr_t pCommand, uint8_t nCommandSize,
55  uintptr_t pRespBuffer, uint16_t nRespBytes, bool bWrite);
56 
57  virtual uint64_t executeRequest(
58  uint64_t p1, uint64_t p2, uint64_t p3, uint64_t p4, uint64_t p5,
59  uint64_t p6, uint64_t p7, uint64_t p8);
60 
61  // IRQ handler callback.
62  virtual bool irq(irq_id_t number, InterruptState &state);
63 
64  IoBase *m_pCommandRegs;
65  IoBase *m_pControlRegs;
66 
67  private:
69  void operator=(const PciAtaController &);
70 
71  enum
72  {
73  UnknownController,
74  PIIX,
75  PIIX3,
76  PIIX4,
77  ICH,
78  ICH0,
79  ICH2,
80  ICH3,
81  ICH4,
82  ICH5
83  } m_PciControllerType;
84 
85  void diskHelper(
86  bool master, IoBase *cmd, IoBase *ctl, BusMasterIde *dma, size_t irq);
87 
88  protected:
89  int m_nController;
90 };
91 
92 #endif
Definition: cmd.h:30
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 bool irq(irq_id_t number, InterruptState &state)
Definition: String.h:49
Abstrace base class for hardware I/O capabilities.
Definition: IoBase.h:31
virtual void getName(String &str)
PciAtaController(Controller *pDev, int nController=0)