Annotation of nono/vm/device.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: 
                      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: 
                     65: //
                     66: // IODevice
                     67: //
                     68: 
                     69: // コンストラクタ
                     70: IODevice::IODevice()
                     71: {
                     72:        devaddr = 0;
                     73:        devlen  = 0;
                     74: }
                     75: 
                     76: // デストラクタ
                     77: IODevice::~IODevice()
                     78: {
                     79: }
                     80: 
                     81: uint64
                     82: IODevice::Read8(uint32 addr)
                     83: {
                     84:        return 0xff;
                     85: }
                     86: 
                     87: uint64
                     88: IODevice::Read16(uint32 addr)
                     89: {
                     90:        return (Read8(addr) << 8) | Read8(addr + 1);
                     91: }
                     92: 
                     93: uint64
                     94: IODevice::Read32(uint32 addr)
                     95: {
                     96:        return (Read16(addr) << 16) | Read16(addr + 2);
                     97: }
                     98: 
                     99: uint64
                    100: IODevice::Write8(uint32 addr, uint32 data)
                    101: {
                    102:        return 0;
                    103: }
                    104: 
                    105: uint64
                    106: IODevice::Write16(uint32 addr, uint32 data)
                    107: {
                    108:        int64 berr;
                    109: 
1.1.1.2   root      110:        berr = Write8(addr, data >> 8);
1.1       root      111:        if (berr < 0)
                    112:                return berr;
                    113:        berr = Write8(addr + 1, data & 0xff);
                    114:        if (berr < 0)
                    115:                return berr;
                    116:        return 0;
                    117: }
                    118: 
                    119: uint64
                    120: IODevice::Write32(uint32 addr, uint32 data)
                    121: {
                    122:        int64 berr;
                    123: 
                    124:        berr = Write16(addr, data >> 16);
                    125:        if (berr < 0)
                    126:                return berr;
                    127:        berr = Write16(addr + 2, data & 0xffff);
                    128:        if (berr < 0)
                    129:                return berr;
                    130:        return 0;
                    131: }
                    132: 
                    133: uint64
                    134: IODevice::Peek8(uint32 addr)
                    135: {
1.1.1.2   root      136:        return 0xff;
1.1       root      137: }
                    138: 
                    139: 
                    140: //
                    141: // バスエラー
                    142: //
                    143: 
1.1.1.6 ! root      144: std::unique_ptr<BusErrDevice> gBusErr;
        !           145: 
1.1       root      146: // コンストラクタ
                    147: BusErrDevice::BusErrDevice()
                    148: {
1.1.1.4   root      149:        logname = "buserr";
1.1       root      150:        devname = "(BusErr)";
                    151:        devaddr = -1;   // XXX どうしたもんか
                    152: }
                    153: 
                    154: BusErrDevice::~BusErrDevice()
                    155: {
                    156: }
                    157: 
                    158: uint64
                    159: BusErrDevice::Read8(uint32 addr)
                    160: {
1.1.1.4   root      161:        putlog(1, "$%08x.b", addr);
1.1       root      162:        return (uint64)-1;
                    163: }
                    164: 
                    165: uint64
                    166: BusErrDevice::Read16(uint32 addr)
                    167: {
1.1.1.4   root      168:        putlog(1, "$%08x.w", addr);
1.1       root      169:        return (uint64)-1;
                    170: }
                    171: 
                    172: uint64
                    173: BusErrDevice::Read32(uint32 addr)
                    174: {
1.1.1.4   root      175:        putlog(1, "$%08x.l", addr);
1.1       root      176:        return (uint64)-1;
                    177: }
                    178: 
                    179: uint64
                    180: BusErrDevice::Write8(uint32 addr, uint32 data)
                    181: {
1.1.1.4   root      182:        putlog(1, "$%08x.b <- %02X", addr, data);
1.1       root      183:        return (uint64)-1;
                    184: }
                    185: 
                    186: uint64
                    187: BusErrDevice::Write16(uint32 addr, uint32 data)
                    188: {
1.1.1.4   root      189:        putlog(1, "$%08x.w <- %04X", addr, data);
1.1       root      190:        return (uint64)-1;
                    191: }
                    192: 
                    193: uint64
                    194: BusErrDevice::Write32(uint32 addr, uint32 data)
                    195: {
1.1.1.4   root      196:        putlog(1, "$%08x.l <- %08X", addr, data);
1.1       root      197:        return (uint64)-1;
                    198: }
                    199: 
                    200: uint64
                    201: BusErrDevice::Peek8(uint32 addr)
                    202: {
                    203:        return (uint64)-1;
                    204: }
                    205: 
                    206: 
                    207: //
                    208: // 何もしないデバイス
                    209: //
                    210: 
1.1.1.5   root      211: std::unique_ptr<NullDevice> gNull;
                    212: 
1.1       root      213: // コンストラクタ
                    214: NullDevice::NullDevice()
                    215: {
1.1.1.5   root      216:        logname = "null";
1.1       root      217:        devname = "(Null)";
                    218: }
                    219: 
                    220: NullDevice::~NullDevice()
                    221: {
                    222: }
                    223: 
                    224: uint64
                    225: NullDevice::Read8(uint32 addr)
                    226: {
1.1.1.5   root      227:        putlog(1, "$%08x.b", addr);
1.1       root      228:        return 0xff;
                    229: }
                    230: 
                    231: uint64
1.1.1.5   root      232: NullDevice::Read16(uint32 addr)
                    233: {
                    234:        putlog(1, "$%08x.w", addr);
                    235:        return 0xffff;
                    236: }
                    237: 
                    238: uint64
                    239: NullDevice::Read32(uint32 addr)
                    240: {
                    241:        putlog(1, "$%08x.l", addr);
                    242:        return 0xffffffff;
                    243: }
                    244: 
                    245: uint64
1.1       root      246: NullDevice::Write8(uint32 addr, uint32 data)
                    247: {
1.1.1.5   root      248:        putlog(1, "$%08x.b <- $%02x", addr, data);
                    249:        return 0;
                    250: }
                    251: 
                    252: uint64
                    253: NullDevice::Write16(uint32 addr, uint32 data)
                    254: {
                    255:        putlog(1, "$%08x.w <- $%04x", addr, data);
                    256:        return 0;
                    257: }
                    258: 
                    259: uint64
                    260: NullDevice::Write32(uint32 addr, uint32 data)
                    261: {
                    262:        putlog(1, "$%08x.l <- $%08x", addr, data);
1.1       root      263:        return 0;
                    264: }
                    265: 
                    266: uint64
                    267: NullDevice::Peek8(uint32 addr)
                    268: {
                    269:        return 0xff;
                    270: }

unix.superglobalmegacorp.com

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