Annotation of nono/vm/mpu.cpp, revision 1.1.1.14

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.9   root        7: //
1.1.1.13  root        8: // MPU (共通部分)
1.1.1.9   root        9: //
1.1.1.2   root       10: 
1.1.1.11  root       11: // Device
                     12: //    |  +-----------+
1.1.1.13  root       13: //    +--| MPUDevice | (全 MPU の共通部)
                     14: //       +-----------+
                     15: //         |
                     16: //         |  +---------------+
                     17: //         +--| MainMPUDevice | (680x0/88xx0 の共通部)
                     18: //         |  +---------------+
                     19: //         |    |
                     20: //         |    +-- MPU680x0Device
                     21: //         |    +-- MPU88xx0Device
                     22: //         |
                     23: //         +-- MPU64180Device
1.1.1.11  root       24: 
1.1       root       25: #include "mpu.h"
1.1.1.5   root       26: #include "config.h"
1.1.1.11  root       27: #include "debugger.h"
                     28: #include "mainbus.h"
1.1.1.9   root       29: #include "scheduler.h"
1.1.1.11  root       30: #include "syncer.h"
1.1       root       31: 
1.1.1.13  root       32: //
                     33: // 全 MPU 共通
                     34: //
                     35: 
1.1       root       36: // コンストラクタ
1.1.1.13  root       37: MPUDevice::MPUDevice(uint objid_)
                     38:        : inherited(objid_)
1.1       root       39: {
                     40: }
                     41: 
                     42: // デストラクタ
                     43: MPUDevice::~MPUDevice()
                     44: {
                     45: }
1.1.1.4   root       46: 
1.1.1.11  root       47: // 初期化
1.1.1.5   root       48: bool
                     49: MPUDevice::Init()
                     50: {
1.1.1.11  root       51:        if (inherited::Init() == false) {
                     52:                return false;
                     53:        }
                     54: 
                     55:        debugger = GetDebugger();
1.1.1.13  root       56: 
                     57:        // パラメータは継承側でセットしている。
                     58:        scheduler->RegistEvent(exec_event);
                     59: 
                     60:        return true;
                     61: }
                     62: 
                     63: void
                     64: MPUDevice::PowerOff()
                     65: {
                     66:        scheduler->StopEvent(exec_event);
                     67: }
                     68: 
                     69: 
                     70: //
                     71: // メイン MPU (680x0/88xx0) 共通部
                     72: //
                     73: 
                     74: // コンストラクタ
                     75: MainMPUDevice::MainMPUDevice()
                     76:        : inherited(OBJ_MPU)
                     77: {
                     78: }
                     79: 
                     80: // デストラクタ
                     81: MainMPUDevice::~MainMPUDevice()
                     82: {
                     83: }
                     84: 
                     85: // 初期化
                     86: bool
                     87: MainMPUDevice::Init()
                     88: {
                     89:        if (inherited::Init() == false) {
                     90:                return false;
                     91:        }
                     92: 
1.1.1.11  root       93:        mainbus = GetMainbusDevice();
                     94:        syncer = GetSyncer();
                     95: 
1.1.1.14! root       96:        // MPU クロック。
        !            97:        // 設定の "mpu-clock" は MHz 単位だが、変数 clock_khz は kHz 単位。
1.1.1.13  root       98:        int val;
1.1.1.14! root       99:        const ConfigItem& item = gConfig->Find("mpu-clock");
1.1.1.13  root      100:        if (item.TryFixedDecimal(&val, 3) == false) {
                    101:                item.Err();
                    102:                return false;
                    103:        }
                    104:        clock_khz = (uint)val;
1.1.1.7   root      105:        // 1MHz 未満はエラー。実際 10MHz 未満でもいい気がするけど
1.1.1.5   root      106:        if (clock_khz < 1000) {
                    107:                item.Err();
                    108:                return false;
                    109:        }
1.1.1.9   root      110:        clock_nsec = 1000 * 1000 / clock_khz;
1.1.1.14! root      111:        if (clock_nsec < 1) {
        !           112:                item.Err("Clock speed too high");
        !           113:                return false;
        !           114:        }
1.1.1.5   root      115: 
1.1.1.13  root      116:        scheduler->ConnectMessage(MessageID::MPU_TRACE_MAIN, this,
                    117:                ToMessageCallback(&MainMPUDevice::TraceMessage));
1.1.1.8   root      118: 
1.1.1.13  root      119:        exec_event.SetName("MPU Execute");
                    120: 
                    121:        return true;
1.1.1.9   root      122: }
                    123: 
                    124: // MPU トレース状態設定要求メッセージ
                    125: void
1.1.1.13  root      126: MainMPUDevice::TraceMessage(MessageID msgid, uint32 arg)
1.1.1.9   root      127: {
1.1.1.10  root      128:        // リセット中は SetTrace しない
                    129:        if (resetting) {
                    130:                return;
                    131:        }
                    132: 
1.1.1.9   root      133:        // デバッガから MPU のトレース状態を設定してくれと言われた
                    134:        SetTrace((bool)arg);
                    135: }
                    136: 
1.1.1.8   root      137: // Round Mode (モニタ表示用)
                    138: /*static*/ const char * const
1.1.1.13  root      139: MainMPUDevice::rmstr[4] = {
1.1.1.8   root      140:        "Near",
                    141:        "Zero",
                    142:        "Minus",
                    143:        "Plus",
                    144: };

unix.superglobalmegacorp.com

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