|
|
1.1 root 1: //
2: // nono
1.1.1.4 root 3: // Copyright (C) 2020 nono project
4: // Licensed under nono-license.txt
1.1 root 5: //
6:
7: #include "sysclk.h"
1.1.1.6 root 8: #include "config.h"
9: #include "interrupt.h"
10:
11: std::unique_ptr<SysClkDevice> gSysClk;
1.1 root 12:
13: SysClkDevice::SysClkDevice()
14: {
15: logname = "sysclk";
16: devname = "SystemClock";
17: devaddr = 0x63000000;
18:
19: event.dev = this;
20: event.func = (DeviceCallback_t)&SysClkDevice::Callback;
21: event.code = 0;
1.1.1.2 root 22: event.SetName("System Clock");
1.1 root 23: }
24:
25: SysClkDevice::~SysClkDevice()
26: {
27: }
28:
29: bool
1.1.1.4 root 30: SysClkDevice::Init()
31: {
32: // クロックは機種ごとに異なる
33: const ConfigItem& item = gConfig->Find("!sysclk-period");
34: event.time = item.AsInt();
35: return true;
36: }
37:
38: bool
1.1 root 39: SysClkDevice::PowerOn()
40: {
41: // 電源オンですぐ起動
1.1.1.8 ! root 42: sysint = false;
1.1.1.3 root 43: event.Start();
1.1 root 44: return true;
45: }
46:
47: uint64
1.1.1.7 root 48: SysClkDevice::Read(uint32 offset)
1.1 root 49: {
1.1.1.3 root 50: // 1 ポートしかない
51: return GetInt();
52: }
1.1 root 53:
1.1.1.3 root 54: uint64
1.1.1.7 root 55: SysClkDevice::Write(uint32 offset, uint32 data)
1.1.1.3 root 56: {
57: // 何か書き込まれたら、フラグをクリア
58: putlog(1, "システムクロック割り込みクリア");
1.1.1.6 root 59: sysint = false;
60: gInterrupt->NegateINT(this);
1.1.1.3 root 61: return 0;
1.1 root 62: }
63:
64: uint64
1.1.1.7 root 65: SysClkDevice::Peek(uint32 offset)
1.1 root 66: {
1.1.1.3 root 67: return GetInt();
68: }
69:
70: // 割り込み状態を取得(?)
71: uint8
72: SysClkDevice::GetInt() const
73: {
74: uint8 data = 0;
1.1 root 75:
1.1.1.3 root 76: if (sysint) {
77: data |= 0x80;
1.1 root 78: }
1.1.1.3 root 79: return data;
1.1 root 80: }
81:
82: // イベントハンドラ
83: void
1.1.1.5 root 84: SysClkDevice::Callback(Event& ev)
1.1 root 85: {
86: putlog(3, "システムクロック割り込み発生");
87: sysint = true;
1.1.1.6 root 88: gInterrupt->AssertINT(this);
1.1.1.5 root 89: ev.Start();
1.1 root 90: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.