xaizek / tos (License: GPLv3 only) (since 2018-12-07)
This is an alternative version of sources presented as part of Write Your Own OS video tutorial by Viktor Engelmann.
<root> / src / drv / ATA.hpp (67d6ec03b848ed2f0c84ac49ac8586693445795b) (919B) (mode 100644) [raw]
#ifndef TOS__DRIVERS__ATA_HPP__
#define TOS__DRIVERS__ATA_HPP__

#include <cstdint>

#include "hwcomm/Port.hpp"
#include "hwcomm/interrupts.hpp"
#include "utils/span.hpp"

namespace drv {

class ATA
{
public:
    ATA(bool master, std::uint16_t portBase);

public:
    void identify();
    void read28(std::uint32_t sectorNum, span<std::uint8_t> buf);
    void write28(std::uint32_t sectorNum, span<const std::uint8_t> buf);
    void flush();

private:
    void waitWhileBusy();
    // Returns `false` on error.
    bool waitUntilReady();

private:
    hwcomm::Port16 dataPort;
    hwcomm::Port8 errorPort;
    hwcomm::Port8 sectorCountPort;
    hwcomm::Port8 lbaLowPort;
    hwcomm::Port8 lbaMidPort;
    hwcomm::Port8 lbaHiPort;
    hwcomm::Port8 devicePort;
    hwcomm::Port8 commandPort;
    hwcomm::Port8 statusPort;
    hwcomm::Port8 controlPort;

    std::uint8_t devBit;
};

}

#endif // TOS__DRIVERS__ATA_HPP__
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/tos

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/tos

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master