Annotation of nono/vm/qemusysctlr.cpp, revision 1.1.1.2

1.1       root        1: //
                      2: // nono
                      3: // Copyright (C) 2024 nono project
                      4: // Licensed under nono-license.txt
                      5: //
                      6: 
                      7: //
                      8: // QEMU Virtual System Controller
                      9: //
                     10: 
                     11: // https://www.qemu.org/docs/master/specs/virt-ctlr.html
                     12: 
                     13: #include "qemusysctlr.h"
1.1.1.2 ! root       14: #include "mpu.h"
1.1       root       15: #include "power.h"
                     16: 
                     17: // コンストラクタ
                     18: QemuSysCtlrDevice::QemuSysCtlrDevice()
                     19:        : inherited(OBJ_QEMUSYSCTLR)
                     20: {
                     21: }
                     22: 
                     23: // デストラクタ
                     24: QemuSysCtlrDevice::~QemuSysCtlrDevice()
                     25: {
                     26: }
                     27: 
                     28: busdata
1.1.1.2 ! root       29: QemuSysCtlrDevice::ReadPort(uint32 offset)
1.1       root       30: {
1.1.1.2 ! root       31:        busdata data;
1.1       root       32: 
                     33:        if (offset == 0) {
                     34:                // Features (Read Only)
1.1.1.2 ! root       35:                data = FEATURES;
        !            36:                putlog(2, "FEATURES -> $%08x", data.Data());
1.1       root       37:        } else {
                     38:                // 他のポートがどうなるのかは仕様に書いてない。
1.1.1.2 ! root       39:                data.SetBusErr();
        !            40:                putlog(1, "Read $%08x (BusErr)", mpu->GetPaddr());
1.1       root       41:        }
1.1.1.2 ! root       42: 
        !            43:        data |= BusData::Size4;
        !            44:        return data;
1.1       root       45: }
                     46: 
                     47: busdata
1.1.1.2 ! root       48: QemuSysCtlrDevice::WritePort(uint32 offset, uint32 data)
1.1       root       49: {
1.1.1.2 ! root       50:        busdata r;
1.1       root       51: 
1.1.1.2 ! root       52:        if (offset == 1) {
1.1       root       53:                // Command (Write Only)
                     54:                static const char *cmdname[] = {
                     55:                        "no-op",
                     56:                        "reset",
                     57:                        "halt",
                     58:                        "panic",
                     59:                };
                     60:                putlog(1, "Command <- $%08x (%s)", data,
                     61:                        (data < countof(cmdname) ? cmdname[data] : cmdname[0]));
                     62:                switch (data) {
                     63:                 default:
                     64:                 case 0:        // no-op
                     65:                        break;
                     66: 
                     67:                 case 1:        // reset
                     68:                        GetPowerDevice()->MakeResetHard();
                     69:                        break;
                     70: 
                     71:                 case 2:        // halt
                     72:                 case 3:        // panic
                     73:                        GetPowerDevice()->PushPowerButton();
                     74:                        break;
                     75:                }
                     76:        } else {
                     77:                // 他のポートがどうなるのかは仕様に書いてない。
1.1.1.2 ! root       78:                putlog(1, "Write $%08x <- $%08x (BusErr)", mpu->GetPaddr(), data);
        !            79:                r.SetBusErr();
1.1       root       80:        }
1.1.1.2 ! root       81: 
        !            82:        r |= BusData::Size4;
        !            83:        return r;
1.1       root       84: }
                     85: 
                     86: busdata
1.1.1.2 ! root       87: QemuSysCtlrDevice::PeekPort(uint32 offset)
1.1       root       88: {
                     89:        switch (offset) {
1.1.1.2 ! root       90:         case 0:        return FEATURES;
1.1       root       91:         default:
1.1.1.2 ! root       92:                return BusData::BusErr;
1.1       root       93:        }
                     94: }

unix.superglobalmegacorp.com

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