Annotation of nono/vm/device.cpp, revision 1.1.1.3

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: 
                      7: #include "device.h"
                      8: #include "vm.h"
                      9: 
                     10: // 全デバイスリスト
                     11: std::vector<Device *> gDevices;
                     12: 
                     13: //
                     14: // Device
                     15: //
                     16: 
                     17: // コンストラクタ
                     18: Device::Device()
                     19: {
                     20:        gDevices.push_back(this);
                     21: }
                     22: 
                     23: // デストラクタ
                     24: Device::~Device()
                     25: {
                     26: }
                     27: 
                     28: bool
                     29: Device::Create()
                     30: {
                     31:        return true;
                     32: }
                     33: 
                     34: bool
                     35: Device::Init()
                     36: {
                     37:        return true;
                     38: }
                     39: 
                     40: bool
                     41: Device::Apply()
                     42: {
                     43:        return true;
                     44: }
                     45: 
                     46: bool
                     47: Device::PowerOn()
                     48: {
                     49:        return true;
                     50: }
                     51: 
                     52: bool
                     53: Device::PowerOff()
                     54: {
                     55:        return true;
                     56: }
                     57: 
                     58: // 本体リセットスイッチによるリセット
                     59: void
                     60: Device::ResetHard()
                     61: {
                     62: }
                     63: 
                     64: // MPU の RESET 命令によるリセット
                     65: void
                     66: Device::ResetSoft()
                     67: {
                     68: }
                     69: 
                     70: 
                     71: //
                     72: // IODevice
                     73: //
                     74: 
                     75: // コンストラクタ
                     76: IODevice::IODevice()
                     77: {
                     78:        devaddr = 0;
                     79:        devlen  = 0;
                     80: }
                     81: 
                     82: // デストラクタ
                     83: IODevice::~IODevice()
                     84: {
                     85: }
                     86: 
                     87: uint64
                     88: IODevice::Read8(uint32 addr)
                     89: {
                     90:        return 0xff;
                     91: }
                     92: 
                     93: uint64
                     94: IODevice::Read16(uint32 addr)
                     95: {
                     96:        return (Read8(addr) << 8) | Read8(addr + 1);
                     97: }
                     98: 
                     99: uint64
                    100: IODevice::Read32(uint32 addr)
                    101: {
                    102:        return (Read16(addr) << 16) | Read16(addr + 2);
                    103: }
                    104: 
                    105: uint64
                    106: IODevice::Write8(uint32 addr, uint32 data)
                    107: {
                    108:        return 0;
                    109: }
                    110: 
                    111: uint64
                    112: IODevice::Write16(uint32 addr, uint32 data)
                    113: {
                    114:        int64 berr;
                    115: 
1.1.1.2   root      116:        berr = Write8(addr, data >> 8);
1.1       root      117:        if (berr < 0)
                    118:                return berr;
                    119:        berr = Write8(addr + 1, data & 0xff);
                    120:        if (berr < 0)
                    121:                return berr;
                    122:        return 0;
                    123: }
                    124: 
                    125: uint64
                    126: IODevice::Write32(uint32 addr, uint32 data)
                    127: {
                    128:        int64 berr;
                    129: 
                    130:        berr = Write16(addr, data >> 16);
                    131:        if (berr < 0)
                    132:                return berr;
                    133:        berr = Write16(addr + 2, data & 0xffff);
                    134:        if (berr < 0)
                    135:                return berr;
                    136:        return 0;
                    137: }
                    138: 
                    139: uint64
                    140: IODevice::Peek8(uint32 addr)
                    141: {
1.1.1.2   root      142:        return 0xff;
1.1       root      143: }
                    144: 
                    145: 
                    146: //
                    147: // バスエラー
                    148: //
                    149: 
                    150: // コンストラクタ
                    151: BusErrDevice::BusErrDevice()
                    152: {
                    153:        devname = "(BusErr)";
                    154:        devaddr = -1;   // XXX どうしたもんか
                    155: }
                    156: 
                    157: BusErrDevice::~BusErrDevice()
                    158: {
                    159: }
                    160: 
                    161: uint64
                    162: BusErrDevice::Read8(uint32 addr)
                    163: {
                    164:        return (uint64)-1;
                    165: }
                    166: 
                    167: uint64
                    168: BusErrDevice::Read16(uint32 addr)
                    169: {
                    170:        return (uint64)-1;
                    171: }
                    172: 
                    173: uint64
                    174: BusErrDevice::Read32(uint32 addr)
                    175: {
                    176:        return (uint64)-1;
                    177: }
                    178: 
                    179: uint64
                    180: BusErrDevice::Write8(uint32 addr, uint32 data)
                    181: {
                    182:        return (uint64)-1;
                    183: }
                    184: 
                    185: uint64
                    186: BusErrDevice::Write16(uint32 addr, uint32 data)
                    187: {
                    188:        return (uint64)-1;
                    189: }
                    190: 
                    191: uint64
                    192: BusErrDevice::Write32(uint32 addr, uint32 data)
                    193: {
                    194:        return (uint64)-1;
                    195: }
                    196: 
                    197: uint64
                    198: BusErrDevice::Peek8(uint32 addr)
                    199: {
                    200:        return (uint64)-1;
                    201: }
                    202: 
                    203: 
                    204: //
                    205: // 何もしないデバイス
                    206: //
                    207: 
                    208: // コンストラクタ
                    209: NullDevice::NullDevice()
                    210: {
                    211:        devname = "(Null)";
                    212: }
                    213: 
                    214: NullDevice::~NullDevice()
                    215: {
                    216: }
                    217: 
                    218: uint64
                    219: NullDevice::Read8(uint32 addr)
                    220: {
                    221:        return 0xff;
                    222: }
                    223: 
                    224: uint64
                    225: NullDevice::Write8(uint32 addr, uint32 data)
                    226: {
                    227:        return 0;
                    228: }
                    229: 
                    230: uint64
                    231: NullDevice::Peek8(uint32 addr)
                    232: {
                    233:        return 0xff;
                    234: }

unix.superglobalmegacorp.com

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