Annotation of nono/vm/mpu.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: 
1.1.1.2   root        7: // MPU 共通部
                      8: 
1.1       root        9: #include "mpu.h"
1.1.1.5   root       10: #include "config.h"
1.1       root       11: 
1.1.1.2   root       12: std::unique_ptr<MPUDevice> gMPU;
1.1       root       13: 
                     14: // コンストラクタ
1.1.1.2   root       15: MPUDevice::MPUDevice()
1.1       root       16: {
                     17:        logname = "mpu";
                     18:        devname = "MPU";
                     19: }
                     20: 
                     21: // デストラクタ
                     22: MPUDevice::~MPUDevice()
                     23: {
                     24: }
1.1.1.4   root       25: 
1.1.1.5   root       26: bool
                     27: MPUDevice::Init()
                     28: {
                     29:        // MPU クロック
                     30:        const ConfigItem& item = gConfig->Find("mpu-clock");
                     31:        const std::string& val = item.AsString();
                     32:        if (val.empty()) {
                     33:                item.Err();
                     34:                return false;
                     35:        }
                     36:        // 文字列を double に変換
                     37:        char *end;
                     38:        errno = 0;
                     39:        double f = strtod(val.c_str(), &end);
                     40:        if (end == val.c_str() || end[0] != '\0' || errno == ERANGE) {
                     41:                item.Err();
                     42:                return false;
                     43:        }
                     44:        // 設定の "mpu-clock" は MHz 単位だが、変数 clock_khz は kHz 単位。
                     45:        clock_khz = (int)(f * 1000);
                     46:        // 1MHz 以下はエラー。実際 10MHz 以下でもいい気がするけど
                     47:        if (clock_khz < 1000) {
                     48:                item.Err();
                     49:                return false;
                     50:        }
                     51: 
                     52:        return true;
                     53: }

unix.superglobalmegacorp.com

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