From c1886bef7c3ea148a10539b6c72a1b69c8fba421 Mon Sep 17 00:00:00 2001 From: Baptiste Wicht Date: Fri, 5 Aug 2016 15:07:46 +0200 Subject: [PATCH] Export ata constants in own header --- kernel/include/ata_constants.hpp | 49 ++++++++++++++++++++++++++++++++ kernel/src/ata.cpp | 36 +---------------------- 2 files changed, 50 insertions(+), 35 deletions(-) create mode 100644 kernel/include/ata_constants.hpp diff --git a/kernel/include/ata_constants.hpp b/kernel/include/ata_constants.hpp new file mode 100644 index 00000000..ed740453 --- /dev/null +++ b/kernel/include/ata_constants.hpp @@ -0,0 +1,49 @@ +//======================================================================= +// Copyright Baptiste Wicht 2013-2016. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +//======================================================================= + +#ifndef ATA_CONSTANTS_HPP +#define ATA_CONSTANTS_HPP + +#include + +//IDE Controllers +#define ATA_PRIMARY 0x1F0 +#define ATA_SECONDARY 0x170 + +// I/O Controllers ports +#define ATA_DATA 0 +#define ATA_ERROR 1 +#define ATA_NSECTOR 2 +#define ATA_SECTOR 3 +#define ATA_LCYL 4 +#define ATA_HCYL 5 +#define ATA_DRV_HEAD 6 +#define ATA_STATUS 7 +#define ATA_COMMAND 7 +#define ATA_DEV_CTL 0x206 + +// Status bits +#define ATA_STATUS_BSY 0x80 +#define ATA_STATUS_DRDY 0x40 +#define ATA_STATUS_DRQ 0x08 +#define ATA_STATUS_ERR 0x01 +#define ATA_STATUS_DF 0x20 + +// Commands +#define ATA_IDENTIFY 0xEC +#define ATAPI_IDENTIFY 0xA1 +#define ATA_READ_BLOCK 0x20 +#define ATA_WRITE_BLOCK 0x30 + +#define ATA_CTL_SRST 0x04 +#define ATA_CTL_nIEN 0x02 + +//Master/Slave on devices +#define MASTER_BIT 0 +#define SLAVE_BIT 1 + +#endif diff --git a/kernel/src/ata.cpp b/kernel/src/ata.cpp index cde9fad6..0a821c73 100644 --- a/kernel/src/ata.cpp +++ b/kernel/src/ata.cpp @@ -8,6 +8,7 @@ #include #include "ata.hpp" +#include "ata_constants.hpp" #include "kernel_utils.hpp" #include "kalloc.hpp" #include "thor.hpp" @@ -21,41 +22,6 @@ namespace { static constexpr const size_t BLOCK_SIZE = 512; -//IDE Controllers -#define ATA_PRIMARY 0x1F0 -#define ATA_SECONDARY 0x170 - -// I/O Controllers ports -#define ATA_DATA 0 -#define ATA_ERROR 1 -#define ATA_NSECTOR 2 -#define ATA_SECTOR 3 -#define ATA_LCYL 4 -#define ATA_HCYL 5 -#define ATA_DRV_HEAD 6 -#define ATA_STATUS 7 -#define ATA_COMMAND 7 -#define ATA_DEV_CTL 0x206 - -// Status bits -#define ATA_STATUS_BSY 0x80 -#define ATA_STATUS_DRDY 0x40 -#define ATA_STATUS_DRQ 0x08 -#define ATA_STATUS_ERR 0x01 - -// Commands -#define ATA_IDENTIFY 0xEC -#define ATAPI_IDENTIFY 0xA1 -#define ATA_READ_BLOCK 0x20 -#define ATA_WRITE_BLOCK 0x30 - -#define ATA_CTL_SRST 0x04 -#define ATA_CTL_nIEN 0x02 - -//Master/Slave on devices -#define MASTER_BIT 0 -#define SLAVE_BIT 1 - ata::drive_descriptor* drives; mutex<> ata_lock;