--- nono/vm/mk48t02.h 2026/04/29 17:04:32 1.1.1.2 +++ nono/vm/mk48t02.h 2026/04/29 17:04:36 1.1.1.3 @@ -1,11 +1,13 @@ // // nono -// Copyright (C) 2018 isaki@NetBSD.org +// Copyright (C) 2020 nono project +// Licensed under nono-license.txt // #pragma once #include "device.h" +#include "mappedfile.h" #include "rtc.h" // MK48T02 の時計部分のレジスタと内部状態 @@ -49,17 +51,17 @@ struct MK48T02Clock class MK48T02Device : public RTCDevice { - typedef RTCDevice inherited; + using inherited = RTCDevice; public: MK48T02Device(); - virtual ~MK48T02Device(); + ~MK48T02Device() override; - virtual bool Init(); - virtual bool InitRTC(); + bool Init() override; + bool InitRTC() override; - virtual bool MonitorUpdate(); + bool MonitorUpdate() override; - virtual void ClockIn(); + void ClockIn() override; // 指定したアドレスからの文字列を読み出す (内蔵 ROM からのアクセス用) std::string PeekString(uint32 addr) const; @@ -83,14 +85,10 @@ class MK48T02Device : public RTCDevice // コントロールレジスタへの書き込み void WriteCtrl(uint32 data); + // ファイル std::string filename {}; - int fd = 0; - - // バイト順はファイルイメージそのままで、2040バイト。 - uint8 *mem = NULL; - - // mmap する長さ - int memlen = 0; + MappedFile file {}; + uint8 *mem {}; // 時計 MK48T02Clock reg {};