summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorLiav A <liavalb@gmail.com>2021-02-20 08:27:50 +0200
committerAndreas Kling <kling@serenityos.org>2021-03-05 11:29:34 +0100
commit566c10b8b82ed5266659af8661abf59787afb3c1 (patch)
tree05056e2aba73cde0eeb0a0a6ba11e765709cb020 /Kernel
parent0e9a2345f99bd4ffb6d198b1215974e0c9e42d5e (diff)
downloadserenity-566c10b8b82ed5266659af8661abf59787afb3c1.zip
Kernel: Make ATA macros to be public
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Storage/ATA.h97
-rw-r--r--Kernel/Storage/IDEChannel.cpp71
2 files changed, 98 insertions, 70 deletions
diff --git a/Kernel/Storage/ATA.h b/Kernel/Storage/ATA.h
new file mode 100644
index 0000000000..1c38fae68f
--- /dev/null
+++ b/Kernel/Storage/ATA.h
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#define ATA_SR_BSY 0x80
+#define ATA_SR_DRDY 0x40
+#define ATA_SR_DF 0x20
+#define ATA_SR_DSC 0x10
+#define ATA_SR_DRQ 0x08
+#define ATA_SR_CORR 0x04
+#define ATA_SR_IDX 0x02
+#define ATA_SR_ERR 0x01
+
+#define ATA_ER_BBK 0x80
+#define ATA_ER_UNC 0x40
+#define ATA_ER_MC 0x20
+#define ATA_ER_IDNF 0x10
+#define ATA_ER_MCR 0x08
+#define ATA_ER_ABRT 0x04
+#define ATA_ER_TK0NF 0x02
+#define ATA_ER_AMNF 0x01
+
+#define ATA_CMD_READ_PIO 0x20
+#define ATA_CMD_READ_PIO_EXT 0x24
+#define ATA_CMD_READ_DMA 0xC8
+#define ATA_CMD_READ_DMA_EXT 0x25
+#define ATA_CMD_WRITE_PIO 0x30
+#define ATA_CMD_WRITE_PIO_EXT 0x34
+#define ATA_CMD_WRITE_DMA 0xCA
+#define ATA_CMD_WRITE_DMA_EXT 0x35
+#define ATA_CMD_CACHE_FLUSH 0xE7
+#define ATA_CMD_CACHE_FLUSH_EXT 0xEA
+#define ATA_CMD_PACKET 0xA0
+#define ATA_CMD_IDENTIFY_PACKET 0xA1
+#define ATA_CMD_IDENTIFY 0xEC
+
+#define ATAPI_CMD_READ 0xA8
+#define ATAPI_CMD_EJECT 0x1B
+
+#define ATA_IDENT_DEVICETYPE 0
+#define ATA_IDENT_CYLINDERS 2
+#define ATA_IDENT_HEADS 6
+#define ATA_IDENT_SECTORS 12
+#define ATA_IDENT_SERIAL 20
+#define ATA_IDENT_MODEL 54
+#define ATA_IDENT_CAPABILITIES 98
+#define ATA_IDENT_FIELDVALID 106
+#define ATA_IDENT_MAX_LBA 120
+#define ATA_IDENT_COMMANDSETS 164
+#define ATA_IDENT_MAX_LBA_EXT 200
+
+#define IDE_ATA 0x00
+#define IDE_ATAPI 0x01
+
+#define ATA_REG_DATA 0x00
+#define ATA_REG_ERROR 0x01
+#define ATA_REG_FEATURES 0x01
+#define ATA_REG_SECCOUNT0 0x02
+#define ATA_REG_LBA0 0x03
+#define ATA_REG_LBA1 0x04
+#define ATA_REG_LBA2 0x05
+#define ATA_REG_HDDEVSEL 0x06
+#define ATA_REG_COMMAND 0x07
+#define ATA_REG_STATUS 0x07
+#define ATA_REG_SECCOUNT1 0x08
+#define ATA_REG_LBA3 0x09
+#define ATA_REG_LBA4 0x0A
+#define ATA_REG_LBA5 0x0B
+#define ATA_CTL_CONTROL 0x00
+#define ATA_CTL_ALTSTATUS 0x00
+#define ATA_CTL_DEVADDRESS 0x01
+
+#define ATA_CAP_LBA 0x200
diff --git a/Kernel/Storage/IDEChannel.cpp b/Kernel/Storage/IDEChannel.cpp
index 103153a639..f5e1b78f6c 100644
--- a/Kernel/Storage/IDEChannel.cpp
+++ b/Kernel/Storage/IDEChannel.cpp
@@ -30,6 +30,7 @@
#include <Kernel/FileSystem/ProcFS.h>
#include <Kernel/IO.h>
#include <Kernel/Process.h>
+#include <Kernel/Storage/ATA.h>
#include <Kernel/Storage/IDEChannel.h>
#include <Kernel/Storage/IDEController.h>
#include <Kernel/Storage/PATADiskDevice.h>
@@ -40,76 +41,6 @@ namespace Kernel {
#define PATA_PRIMARY_IRQ 14
#define PATA_SECONDARY_IRQ 15
-#define ATA_SR_BSY 0x80
-#define ATA_SR_DRDY 0x40
-#define ATA_SR_DF 0x20
-#define ATA_SR_DSC 0x10
-#define ATA_SR_DRQ 0x08
-#define ATA_SR_CORR 0x04
-#define ATA_SR_IDX 0x02
-#define ATA_SR_ERR 0x01
-
-#define ATA_ER_BBK 0x80
-#define ATA_ER_UNC 0x40
-#define ATA_ER_MC 0x20
-#define ATA_ER_IDNF 0x10
-#define ATA_ER_MCR 0x08
-#define ATA_ER_ABRT 0x04
-#define ATA_ER_TK0NF 0x02
-#define ATA_ER_AMNF 0x01
-
-#define ATA_CMD_READ_PIO 0x20
-#define ATA_CMD_READ_PIO_EXT 0x24
-#define ATA_CMD_READ_DMA 0xC8
-#define ATA_CMD_READ_DMA_EXT 0x25
-#define ATA_CMD_WRITE_PIO 0x30
-#define ATA_CMD_WRITE_PIO_EXT 0x34
-#define ATA_CMD_WRITE_DMA 0xCA
-#define ATA_CMD_WRITE_DMA_EXT 0x35
-#define ATA_CMD_CACHE_FLUSH 0xE7
-#define ATA_CMD_CACHE_FLUSH_EXT 0xEA
-#define ATA_CMD_PACKET 0xA0
-#define ATA_CMD_IDENTIFY_PACKET 0xA1
-#define ATA_CMD_IDENTIFY 0xEC
-
-#define ATAPI_CMD_READ 0xA8
-#define ATAPI_CMD_EJECT 0x1B
-
-#define ATA_IDENT_DEVICETYPE 0
-#define ATA_IDENT_CYLINDERS 2
-#define ATA_IDENT_HEADS 6
-#define ATA_IDENT_SECTORS 12
-#define ATA_IDENT_SERIAL 20
-#define ATA_IDENT_MODEL 54
-#define ATA_IDENT_CAPABILITIES 98
-#define ATA_IDENT_FIELDVALID 106
-#define ATA_IDENT_MAX_LBA 120
-#define ATA_IDENT_COMMANDSETS 164
-#define ATA_IDENT_MAX_LBA_EXT 200
-
-#define IDE_ATA 0x00
-#define IDE_ATAPI 0x01
-
-#define ATA_REG_DATA 0x00
-#define ATA_REG_ERROR 0x01
-#define ATA_REG_FEATURES 0x01
-#define ATA_REG_SECCOUNT0 0x02
-#define ATA_REG_LBA0 0x03
-#define ATA_REG_LBA1 0x04
-#define ATA_REG_LBA2 0x05
-#define ATA_REG_HDDEVSEL 0x06
-#define ATA_REG_COMMAND 0x07
-#define ATA_REG_STATUS 0x07
-#define ATA_REG_SECCOUNT1 0x08
-#define ATA_REG_LBA3 0x09
-#define ATA_REG_LBA4 0x0A
-#define ATA_REG_LBA5 0x0B
-#define ATA_CTL_CONTROL 0x00
-#define ATA_CTL_ALTSTATUS 0x00
-#define ATA_CTL_DEVADDRESS 0x01
-
-#define ATA_CAP_LBA 0x200
-
#define PCI_Mass_Storage_Class 0x1
#define PCI_IDE_Controller_Subclass 0x1