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