Annotation of nono/vm/iocon.cpp, revision 1.1

1.1     ! root        1: //
        !             2: // nono
        !             3: // Copyright (C) 2017 [email protected]
        !             4: //
        !             5: 
        !             6: #include "iocon.h"
        !             7: #include "mpu.h"
        !             8: 
        !             9: IOConDevice *gIOCon;
        !            10: 
        !            11: IOConDevice::IOConDevice()
        !            12: {
        !            13:        logname = "iocon";
        !            14:        devname = "IOCtrler";
        !            15:        devaddr = baseaddr;
        !            16:        devlen  = 0x2000;
        !            17: }
        !            18: 
        !            19: IOConDevice::~IOConDevice()
        !            20: {
        !            21: }
        !            22: 
        !            23: uint64
        !            24: IOConDevice::Read8(uint32 addr)
        !            25: {
        !            26:        uint32 offset = addr - baseaddr;
        !            27:        switch (offset) {
        !            28:         case 1:        // $E9C001 割り込みステータス
        !            29:                return (fdc_int ? 0x80 : 0)
        !            30:                        |  (fdd_int ? 0x40 : 0)
        !            31:                        |  (prt_int ? 0x20 : 0)
        !            32:                        |  (hdd_int ? 0x10 : 0)
        !            33:                        |  (hdd_en  ? 0x08 : 0)
        !            34:                        |  (fdc_en  ? 0x04 : 0)
        !            35:                        |  (fdd_en  ? 0x02 : 0)
        !            36:                        |  (prt_en  ? 0x01 : 0);
        !            37:         case 3:        // $E9C003 割り込みベクタ
        !            38:                return vector;
        !            39:                break;
        !            40:        }
        !            41:        return (uint64)-1;
        !            42: }
        !            43: 
        !            44: uint64
        !            45: IOConDevice::Read16(uint32 addr)
        !            46: {
        !            47:        return 0xff00 | Read8(addr + 1);
        !            48: }
        !            49: 
        !            50: uint64
        !            51: IOConDevice::Write8(uint32 addr, uint32 data)
        !            52: {
        !            53:        uint32 offset = addr - baseaddr;
        !            54:        switch (offset) {
        !            55:         case 1:        // $E9C001 割り込みマスク
        !            56:                hdd_en = (data & 0x08);
        !            57:                fdc_en = (data & 0x04);
        !            58:                fdd_en = (data & 0x02);
        !            59:                prt_en = (data & 0x01);
        !            60:                putlog(1, "割り込みマスク設定 HDD=%d FDC=%d FDD=%d PRT=%d",
        !            61:                        hdd_en, fdc_en, fdd_en, prt_en);
        !            62:                return 0;
        !            63:         case 3:        // $E9C003 割り込みベクタ
        !            64:                vector = data & 0xfc;
        !            65:                putlog(1, "割り込みベクタ設定 $%02x", vector);
        !            66:                return 0;
        !            67:         default:
        !            68:                break;
        !            69:        }
        !            70:        return (uint64)-1;
        !            71: }
        !            72: 
        !            73: uint64
        !            74: IOConDevice::Write16(uint32 addr, uint32 data)
        !            75: {
        !            76:        return Write8(addr + 1, data);
        !            77: }
        !            78: 
        !            79: uint64
        !            80: IOConDevice::Peek8(uint32 addr)
        !            81: {
        !            82:        uint32 offset = addr - baseaddr;
        !            83:        switch (offset) {
        !            84:         case 1:
        !            85:                return (fdc_int ? 0x80 : 0)
        !            86:                        |  (fdd_int ? 0x40 : 0)
        !            87:                        |  (prt_int ? 0x20 : 0)
        !            88:                        |  (hdd_int ? 0x10 : 0)
        !            89:                        |  (hdd_en  ? 0x08 : 0)
        !            90:                        |  (fdc_en  ? 0x04 : 0)
        !            91:                        |  (fdd_en  ? 0x02 : 0)
        !            92:                        |  (prt_en  ? 0x01 : 0);
        !            93: 
        !            94:         case 3:
        !            95:                return vector;
        !            96: 
        !            97:         default:
        !            98:                return 0xff;
        !            99:        }
        !           100: }
        !           101: 
        !           102: // FDC からの割り込み要求
        !           103: void
        !           104: IOConDevice::IntFDC()
        !           105: {
        !           106:        fdc_int = true;
        !           107:        if (fdc_en) {
        !           108:                putlog(1, "FDC からの割り込み要求");
        !           109:                gMPU->Interrupt(1, vector + 0);
        !           110:        } else {
        !           111:                putlog(2, "FDC からの割り込み要求(マスク)");
        !           112:        }
        !           113: }

unix.superglobalmegacorp.com

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