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

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

unix.superglobalmegacorp.com

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