|
|
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.8 root 7: //
8: // デバイスの基本クラスなど
9: //
1.1 root 10:
1.1.1.8 root 11: #include "device.h"
12: #include "mpu.h"
13: #include "scheduler.h"
1.1 root 14:
15: //
16: // Device
17: //
18:
19: // コンストラクタ
1.1.1.11 root 20: Device::Device(uint objid_)
1.1.1.9 root 21: : inherited(objid_)
1.1 root 22: {
23: }
24:
25: // デストラクタ
26: Device::~Device()
27: {
28: }
29:
30: bool
31: Device::Create()
32: {
33: return true;
34: }
35:
36: bool
1.1.1.12 root 37: Device::Create2()
38: {
39: return true;
40: }
41:
42: void
43: Device::EarlyInit()
1.1 root 44: {
1.1.1.9 root 45: mpu = GetMPUDevice();
46: scheduler = GetScheduler();
1.1.1.12 root 47: }
1.1.1.9 root 48:
1.1.1.12 root 49: bool
50: Device::Init()
51: {
1.1 root 52: return true;
53: }
54:
1.1.1.8 root 55: void
56: Device::ResetHard(bool poweron)
1.1 root 57: {
58: }
59:
1.1.1.8 root 60: void
1.1 root 61: Device::PowerOff()
62: {
63: }
64:
1.1.1.8 root 65: // ログ表示。
66: // VM デバイスでは、仮想時間、PC、オブジェクト名を表示する。
1.1 root 67: void
1.1.1.8 root 68: Device::putlogn(const char *fmt, ...) const
1.1 root 69: {
1.1.1.8 root 70: char buf[1024];
71: va_list ap;
72: uint64 vt;
73: int len;
74:
1.1.1.9 root 75: vt = scheduler->GetVirtTime();
1.1.1.14! root 76: len = snprintf(buf, sizeof(buf), "%16s %08x %s ",
! 77: SecToStr(vt).c_str(),
1.1.1.9 root 78: mpu->GetPPC(),
1.1.1.8 root 79: GetName().c_str());
80:
81: va_start(ap, fmt);
82: vsnprintf(buf + len, sizeof(buf) - len, fmt, ap);
83: va_end(ap);
84:
85: WriteLog(buf);
1.1 root 86: }
87:
88:
89: //
90: // IODevice
91: //
92:
93: // コンストラクタ
1.1.1.11 root 94: IODevice::IODevice(uint objid_)
1.1.1.9 root 95: : inherited(objid_)
1.1 root 96: {
97: }
98:
99: // デストラクタ
100: IODevice::~IODevice()
101: {
102: }
103:
1.1.1.10 root 104: busdata
1.1.1.11 root 105: IODevice::Read(busaddr addr)
1.1 root 106: {
1.1.1.11 root 107: return 0;
1.1 root 108: }
109:
1.1.1.10 root 110: busdata
1.1.1.11 root 111: IODevice::Write(busaddr addr, uint32 data)
1.1 root 112: {
1.1.1.11 root 113: return 0;
1.1 root 114: }
115:
1.1.1.10 root 116: busdata
1.1.1.11 root 117: IODevice::ReadBurst16(busaddr addr, uint32 *dst)
1.1 root 118: {
1.1.1.11 root 119: return BusData::BusErr;
1.1 root 120: }
121:
1.1.1.10 root 122: busdata
1.1.1.11 root 123: IODevice::WriteBurst16(busaddr addr, const uint32 *src)
1.1 root 124: {
1.1.1.11 root 125: return BusData::BusErr;
1.1 root 126: }
127:
1.1.1.10 root 128: busdata
1.1.1.11 root 129: IODevice::Read1(uint32 addr)
1.1 root 130: {
1.1.1.11 root 131: return 0xff;
1.1 root 132: }
133:
1.1.1.10 root 134: busdata
1.1.1.11 root 135: IODevice::Write1(uint32 addr, uint32 data)
1.1 root 136: {
137: return 0;
138: }
139:
1.1.1.10 root 140: busdata
1.1.1.11 root 141: IODevice::Peek1(uint32 addr)
1.1 root 142: {
1.1.1.2 root 143: return 0xff;
1.1 root 144: }
145:
1.1.1.10 root 146: bool
1.1.1.11 root 147: IODevice::Poke1(uint32 addr, uint32 data)
1.1.1.9 root 148: {
1.1.1.10 root 149: return false;
1.1.1.9 root 150: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.