Export ata constants in own header

This commit is contained in:
Baptiste Wicht 2016-08-05 15:07:46 +02:00
parent 0f16fae4ce
commit c1886bef7c
2 changed files with 50 additions and 35 deletions

View File

@ -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 <types.hpp>
//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

View File

@ -8,6 +8,7 @@
#include <lock_guard.hpp>
#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;