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 / rtl8139.hpp (36ded230afac3d7371ecdc039304a56883cc4709) (1,506B) (mode 100644) [raw]
#ifndef TOS__DRV__RTL8139_HPP__
#define TOS__DRV__RTL8139_HPP__

#include <cstdint>

#include "drv/drivers.hpp"
#include "hwcomm/Port.hpp"
#include "hwcomm/interrupts.hpp"

namespace hwcomm {
    class PCIDeviceDescr;
}

namespace drv {

class rtl8139 : public EthernetDriver, public hwcomm::InterruptHandler
{
public:
    rtl8139(hwcomm::PCIDeviceDescr &dev,
            hwcomm::InterruptManager &interrupts);

public:
    virtual void send(span<const std::uint8_t> msg) override;
    virtual void receive() override;
    virtual NetOrder<std::uint64_t> getMAC() const override;

private:
    virtual void activate() override;
    virtual int reset() override;
    virtual const char * getName() const override;

private:
    virtual std::uint32_t handleInterrupt(std::uint32_t esp) override;

private:
    void received();

private:
    hwcomm::Port32 macLowPort;
    hwcomm::Port32 macHighPort;
    hwcomm::Port32 marLowPort;
    hwcomm::Port32 marHighPort;
    hwcomm::Port32 rbstartPort;
    hwcomm::Port8 cmdPort;
    hwcomm::Port16 caprPort;
    hwcomm::Port16 imrPort;
    hwcomm::Port16 isrPort;
    hwcomm::Port32 tcrPort;
    hwcomm::Port32 rcrPort;
    hwcomm::Port8 cfgPort;
    hwcomm::Port32 tsdPort[4];
    hwcomm::Port32 tsadPort[4];

    int currentSendDescr;
    std::uint64_t mac;

    std::uint8_t *recvBuffer;
    std::uint8_t recvBufferStorage[8192 + 16 + 1500];

    std::uint8_t *sendBuffer[4];
    std::uint8_t sendBufferStorage[4][2000];
};

}

#endif // TOS__DRV__RTL8139_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