|
|
1.1 ! root 1: // ! 2: // nono ! 3: // Copyright (C) 2020 nono project ! 4: // Licensed under nono-license.txt ! 5: // ! 6: ! 7: #include "ioctlr.h" ! 8: #include "mpu680x0.h" ! 9: ! 10: std::unique_ptr<IOCtlrDevice> gIOCtlr; ! 11: ! 12: IOCtlrDevice::IOCtlrDevice() ! 13: { ! 14: logname = "ioctlr"; ! 15: devname = "IOCtlr"; ! 16: devaddr = baseaddr; ! 17: devlen = 0x2000; ! 18: } ! 19: ! 20: IOCtlrDevice::~IOCtlrDevice() ! 21: { ! 22: } ! 23: ! 24: uint64 ! 25: IOCtlrDevice::Read(uint32 addr) ! 26: { ! 27: switch (addr) { ! 28: case 0: // $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: ! 38: case 1: // $E9C003 割り込みベクタ ! 39: // 書き込み専用 ! 40: return 0xff; ! 41: ! 42: default: ! 43: return 0xff; ! 44: } ! 45: } ! 46: ! 47: uint64 ! 48: IOCtlrDevice::Write(uint32 addr, uint32 data) ! 49: { ! 50: switch (addr) { ! 51: case 0: // $E9C001 割り込みマスク ! 52: hdd_en = (data & 0x08); ! 53: fdc_en = (data & 0x04); ! 54: fdd_en = (data & 0x02); ! 55: prt_en = (data & 0x01); ! 56: putlog(1, "割り込みマスク設定 HDD=%d FDC=%d FDD=%d PRT=%d", ! 57: hdd_en, fdc_en, fdd_en, prt_en); ! 58: return 0; ! 59: ! 60: case 1: // $E9C003 割り込みベクタ ! 61: vector = data & 0xfc; ! 62: putlog(1, "割り込みベクタ設定 $%02x", vector); ! 63: return 0; ! 64: ! 65: default: ! 66: return 0; ! 67: } ! 68: } ! 69: ! 70: uint64 ! 71: IOCtlrDevice::Peek(uint32 addr) ! 72: { ! 73: switch (addr) { ! 74: case 0: ! 75: return (fdc_int ? 0x80 : 0) ! 76: | (fdd_int ? 0x40 : 0) ! 77: | (prt_int ? 0x20 : 0) ! 78: | (hdd_int ? 0x10 : 0) ! 79: | (hdd_en ? 0x08 : 0) ! 80: | (fdc_en ? 0x04 : 0) ! 81: | (fdd_en ? 0x02 : 0) ! 82: | (prt_en ? 0x01 : 0); ! 83: ! 84: case 1: ! 85: // 書き込み専用 ! 86: return 0xff; ! 87: ! 88: default: ! 89: return 0xff; ! 90: } ! 91: } ! 92: ! 93: // FDC からの割り込み要求 ! 94: void ! 95: IOCtlrDevice::IntFDC() ! 96: { ! 97: fdc_int = true; ! 98: if (fdc_en) { ! 99: putlog(1, "FDC からの割り込み要求"); ! 100: gMPU680x0->Interrupt(this, 1, vector + 0); ! 101: } else { ! 102: putlog(2, "FDC からの割り込み要求(マスク)"); ! 103: } ! 104: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.