Annotation of nono/vm/ethernet.cpp, revision 1.1.1.6

1.1       root        1: //
                      2: // nono
1.1.1.3   root        3: // Copyright (C) 2020 nono project
                      4: // Licensed under nono-license.txt
1.1       root        5: //
                      6: 
1.1.1.6 ! root        7: //
        !             8: // Ethernet 基本クラス
        !             9: //
        !            10: 
1.1       root       11: #include "ethernet.h"
1.1.1.6 ! root       12: #include "hostnet.h"
        !            13: #include "scheduler.h"
1.1       root       14: 
1.1.1.6 ! root       15: // グローバル参照用
        !            16: EthernetDevice *gEthernet;
1.1       root       17: 
                     18: // コンストラクタ
1.1.1.5   root       19: EthernetDevice::EthernetDevice(const std::string& objname_)
                     20:        : inherited(objname_)
1.1       root       21: {
                     22: }
                     23: 
                     24: // デストラクタ
                     25: EthernetDevice::~EthernetDevice()
                     26: {
1.1.1.6 ! root       27:        if ((bool)hostnet) {
        !            28:                hostnet->SetCallbackDevice(NULL);
        !            29:        }
        !            30:        gEthernet = NULL;
1.1       root       31: }
                     32: 
                     33: // 動的なコンストラクション
                     34: bool
                     35: EthernetDevice::Create()
                     36: {
1.1.1.6 ! root       37:        // ホストドライバを作成してこのデバイスと紐付ける
        !            38:        hostnet.reset(new HostNetDevice());
1.1       root       39: 
1.1.1.6 ! root       40:        hostnet->SetRxCallback(ToDeviceCallback(&EthernetDevice::HostRxCallback));
        !            41:        hostnet->SetCallbackDevice(this);
1.1       root       42: 
                     43:        return true;
                     44: }
                     45: 
1.1.1.6 ! root       46: // これは Host スレッドから呼ばれる
        !            47: void
        !            48: EthernetDevice::HostRxCallback()
1.1.1.5   root       49: {
1.1.1.6 ! root       50:        // スレッドを超えるためにメッセージを投げる
        !            51:        gScheduler->SendMessage(MessageID::HOSTNET_RX);
1.1.1.5   root       52: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.