Annotation of nono/vm/fdc.h, revision 1.1.1.1

1.1       root        1: //
                      2: // nono
                      3: // Copyright (C) 2017 [email protected]
                      4: //
                      5: 
                      6: #pragma once
                      7: 
                      8: #include "device.h"
                      9: #include "scheduler.h"
                     10: 
                     11: enum fdc_phase_t {
                     12:        PHASE_IDLE = 0,
                     13:        PHASE_COMMAND,
                     14:        PHASE_EXEC,
                     15:        PHASE_RESULT,
                     16: };
                     17: 
                     18: struct FDD {
                     19:        bool motor;                             // モーターオン
                     20:        bool seek;                              // シーク中/シーク完了割り込み保留中
                     21: };
                     22: 
                     23: struct FDC {
                     24:        int drivesel;                   // ドライブ選択
                     25:        fdc_phase_t phase;
                     26:        uint8 cmdbuf[10];
                     27:        int cmdpos;
                     28:        int cmdlen;
                     29:        uint8 resbuf[10];
                     30:        int respos;
                     31:        int reslen;
                     32: 
                     33:        bool is2DD;
                     34:        int accdrive;                   // アクセスドライブ番号
                     35: 
                     36:        // ステータスレジスタ
                     37:        bool RQM;                               // Request For Master
                     38:        int DIO;                                // Data Input/Output
                     39: #define DIOtoFDC       (0)
                     40: #define DIOtoHost      (1)
                     41:        bool NDM;                               // Non-DMA Mode
                     42:        bool CB;                                // FDC Busy
                     43: 
                     44:        uint8 srt;
                     45:        uint8 hut;
                     46:        uint8 hlt;
                     47:        bool nd;                                // Non DMA
                     48: 
                     49:        // コマンド(下位5ビットのみにしたもの)
                     50:        static const int CMD_MASK                                       = 0x1f; // マスク
                     51:        static const int CMD_READ_DIAGNOSTIC            = 0x02; // %0M00_0010
                     52:        static const int CMD_SPECIFY                            = 0x03; // %0000_0011
                     53:        static const int CMD_SENSE_DEVICE_STATUS        = 0x04; // %0000_0100
                     54:        static const int CMD_WRITE_DATA                         = 0x05; // %MM00_0101
                     55:        static const int CMD_READ                                       = 0x06; // %MMS0_0110
                     56:        static const int CMD_RECALIBRATE                        = 0x07; // %0000_0111
                     57:        static const int CMD_SENSE_INTERRUPT_STATUS     = 0x08; // %0000_1000
                     58:        static const int CMD_WRITE_DELETED_DATA         = 0x09; // %MM00_1001
                     59:        static const int CMD_READ_ID                            = 0x0a; // %0M00_1010
                     60:        static const int CMD_READ_DELETED_DATA          = 0x0c; // %MMS0_1100
                     61:        static const int CMD_WRITE_ID                           = 0x0d; // %0M00_1101
                     62:        static const int CMD_SEEK                                       = 0x0f; // %0000_1111
                     63:        static const int CMD_SCAN_EQUAL                         = 0x11; // %MMS1_0001
                     64:        static const int CMD_RESET_STANDBY                      = 0x14; // %0011_0100
                     65:        static const int CMD_SET_STABNDBY                       = 0x15; // %0011_0101
                     66:        static const int CMD_SOFTWARE_RESET                     = 0x16; // %0011_0110
                     67:        static const int CMD_SCAN_LOW_OR_EQUAL          = 0x19; // %MMS1_1001
                     68:        static const int CMD_SCAN_HIGH_OR_EQUAL         = 0x1d; // %MMS1_1101
                     69: 
                     70:        // ステータスレジスタ
                     71:        static const int STAT_RQM               = 0x80; // Request For Master
                     72:        static const int STAT_DIO               = 0x40; // Data Input/Output
                     73:        static const int STAT_NDM               = 0x20; // Non-DMA Mode
                     74:        static const int STAT_CB                = 0x10; // FDC Busy
                     75:        static const int STAT_D3B               = 0x08; // FD3 Busy
                     76:        static const int STAT_D2B               = 0x04; // FD2 Busy
                     77:        static const int STAT_D1B               = 0x02; // FD1 Busy
                     78:        static const int STAT_D0B               = 0x01; // FD0 Busy
                     79: 
                     80:        // リザルトステータス0
                     81:        static const int ST0_IC_MASK    = 0xc0;
                     82:        static const int ST0_IC_AI              = 0xc0; // AI: Attention Interrupt
                     83:        static const int ST0_IC_IC              = 0x80; // CI: Invalid Command
                     84:        static const int ST0_IC_AT              = 0x40; // AT: Abnormal Terminate
                     85:        static const int ST0_IC_NT              = 0x00; // NT: Normal Terminate
                     86:        static const int ST0_SE                 = 0x20; // Seek End
                     87:        static const int ST0_EC                 = 0x10; // Equipment Check
                     88:        static const int ST0_NR                 = 0x08; // Not Ready
                     89:        static const int ST0_HD                 = 0x04; // Head Address
                     90:        static const int ST0_US_MASK    = 0x03; // Unit Select
                     91: 
                     92:        // リザルトステータス3
                     93:        static const int ST3_FT                 = 0x80; // Fault
                     94:        static const int ST3_WP                 = 0x40; // Write Protect
                     95:        static const int ST3_RY                 = 0x20; // Ready
                     96:        static const int ST3_T0                 = 0x10; // Track 0
                     97:        static const int ST3_TS                 = 0x08; // Two Side
                     98:        static const int ST3_HD                 = 0x04; // HD
                     99:        static const int ST3_US_MASK    = 0x03; // Unit Select
                    100: };
                    101: 
                    102: class FDCDevice
                    103:        : public IODevice
                    104: {
                    105:        typedef IODevice inherited;
                    106:  private:
                    107:        static const int baseaddr = 0xe94000;
                    108: 
                    109:  public:
                    110:        FDCDevice();
                    111:        virtual ~FDCDevice();
                    112: 
                    113:        virtual void ResetHard();
                    114: 
                    115:        virtual uint64 Read8(uint32 addr);
                    116:        virtual uint64 Read16(uint32 addr);
                    117:        virtual uint64 Write8(uint32 addr, uint32 data);
                    118:        virtual uint64 Write16(uint32 addr, uint32 data);
                    119:        virtual uint64 Peek8(uint32 addr);
                    120: 
                    121:  private:
                    122:        uint32 ReadStatus();
                    123:        uint32 ReadData();
                    124:        uint32 ReadDriveStatus();
                    125:        void WriteCmd(uint32);
                    126: 
                    127:        void idle_phase();
                    128:        void exec_phase();
                    129:        void result_phase();
                    130: 
                    131:        struct FDC fdc {};
                    132:        struct FDD fdd[4] {};
                    133: 
                    134:        void Callback(int);
                    135: 
                    136:        void Interrupt();
                    137: 
                    138:        Event event {};
                    139: 
                    140:        // コマンドを名前に変換
                    141:        static const char *cmd2name(uint32);
                    142: 
                    143:        // コマンド名一覧
                    144:        static const char *cmdnames_str[];
                    145: };

unix.superglobalmegacorp.com

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