diff --git a/ArdSCSinoV2.ino b/ArdSCSinoV2.ino index cf0198d..c30433d 100644 --- a/ArdSCSinoV2.ino +++ b/ArdSCSinoV2.ino @@ -1,28 +1,28 @@ /* - * SCSI-HDデバイスエミュレータ for STM32F103 + * SCSI-HD Device emulator for STM32F103 */ #define X1TURBO_DTC510B 0 /* for SHARP X1turbo */ -#define READ_SPEED_OPTIMIZE 1 /* リードの高速化 */ -#define WRITE_SPEED_OPTIMIZE 1 /* ライトの高速化 */ -#define USE_DB2ID_TABLE 1 /* SEL-DBからIDの取得にテーブル使用 */ +#define READ_SPEED_OPTIMIZE 1 /* Lead speedup */ +#define WRITE_SPEED_OPTIMIZE 1 /* Speed up writes */ +#define USE_DB2ID_TABLE 1 /* SEL-DB Use table to get ID from */ // SCSI config -#define NUM_SCSIID 7 // サポート最大SCSI-ID数 (最小は0) -#define NUM_SCSILUN 2 // サポート最大LUN数 (最小は0) -#define READ_PARITY_CHECK 0 // リードパリティーチェックを行う(未検証) +#define NUM_SCSIID 7 // Maximum number of supported SCSI-IDs (The minimum is 0) +#define NUM_SCSILUN 2 // Maximum number of LUNs supported (The minimum is 0) +#define READ_PARITY_CHECK 0 // Perform read parity check (unverified) // HDD format #if X1TURBO_DTC510B -#define BLOCKSIZE 256 // 1BLOCKサイズ +#define BLOCKSIZE 256 // 1 BLOCK size #else -#define BLOCKSIZE 512 // 1BLOCKサイズ +#define BLOCKSIZE 512 // 1 BLOCK size #endif //#include #include -//SdFatEX CLASSを利用可能にする +//SdFatEX CLASS To make available #undef ENABLE_EXTENDED_TRANSFER_CLASS #define ENABLE_EXTENDED_TRANSFER_CLASS 1 #include @@ -80,7 +80,7 @@ SdFatEX SD(&SPI_1); #define SD_CS PA4 // SDCARD:CS #define LED PC13 // LED -// GPIOレジスタポート +// GPIO register port #define PAREG GPIOA->regs #define PBREG GPIOB->regs @@ -89,10 +89,10 @@ SdFatEX SD(&SPI_1); #define LED_OFF() gpio_write(LED, low); -// 仮想ピン(Arduio互換は遅いのでMCU依存にして) +// Virtual pin (Arduio compatibility is slow, so make it MCU-dependent) #define PA(BIT) (BIT) #define PB(BIT) (BIT+16) -// 仮想ピンのデコード +// Virtual pin decoding #define GPIOREG(VPIN) ((VPIN)>=16?PBREG:PAREG) #define BITMASK(VPIN) (1<<((VPIN)&15)) @@ -107,10 +107,10 @@ SdFatEX SD(&SPI_1); #define vIO PB(7) // SCSI:I/O #define vSD_CS PA(4) // SDCARD:CS -// SCSI 出力ピン制御 : opendrain active LOW (direct pin drive) +// SCSI output pin control: opendrain active LOW (direct pin drive) #define SCSI_OUT(VPIN,ACTIVE) { GPIOREG(VPIN)->BSRR = BITMASK(VPIN)<<((ACTIVE)?16:0); } -// SCSI 入力ピン確認(inactive=0,avtive=1) +// SCSI input pin check (inactive=0,avtive=1) #define SCSI_IN(VPIN) ((~GPIOREG(VPIN)->IDR>>(VPIN&15))&1) // GPIO mode @@ -122,79 +122,79 @@ SdFatEX SD(&SPI_1); #define DB_MODE_OUT 1 #define DB_MODE_IN 8 -// DB,DPを出力モードにする +// Put DB and DP in output mode #define SCSI_DB_OUTPUT() { PBREG->CRL=(PBREG->CRL &0xfffffff0)|DB_MODE_OUT; PBREG->CRH = 0x11111111*DB_MODE_OUT; } -// DB,DPを入力モードにする +// Put DB and DP in input mode #define SCSI_DB_INPUT() { PBREG->CRL=(PBREG->CRL &0xfffffff0)|DB_MODE_IN ; PBREG->CRH = 0x11111111*DB_MODE_IN; } -// BSYだけ出力をON にする +// Turn on the output only for BSY #define SCSI_BSY_ACTIVE() { gpio_mode(BSY, GPIO_OUTPUT_OD); SCSI_OUT(vBSY, active) } -// BSY,REQ,MSG,CD,IO 出力をON にする (ODの場合は変更不要) +// BSY,REQ,MSG,CD,IO Turn on the output (no change required for OD) #define SCSI_TARGET_ACTIVE() { } -// BSY,REQ,MSG,CD,IO 出力をOFFにする、BSYは最後、入力に +// BSY,REQ,MSG,CD,IO Turn off output, BSY is the last input #define SCSI_TARGET_INACTIVE() { SCSI_OUT(vREQ,inactive); SCSI_OUT(vMSG,inactive); SCSI_OUT(vCD,inactive);SCSI_OUT(vIO,inactive); SCSI_OUT(vBSY,inactive); gpio_mode(BSY, GPIO_INPUT_PU); } // HDDiamge file -#define HDIMG_FILE "HDxx.HDS" // HDイメージファイル名ベース -#define HDIMG_ID_POS 2 // ID数字を埋め込む位置 -#define HDIMG_LUN_POS 3 // LUN数字を埋め込む位置 +#define HDIMG_FILE "HDxx.HDS" // HD image file name base +#define HDIMG_ID_POS 2 // Position to embed ID number +#define HDIMG_LUN_POS 3 // Position to embed LUN numbers // HDD image typedef struct hddimg_struct { - File m_file; // ファイルオブジェクト - uint32_t m_fileSize; // ファイルサイズ + File m_file; // File object + uint32_t m_fileSize; // File size }HDDIMG; -HDDIMG img[NUM_SCSIID][NUM_SCSILUN]; // 最大個数分 +HDDIMG img[NUM_SCSIID][NUM_SCSILUN]; // Maximum number -uint8_t m_senseKey = 0; //センスキー -volatile bool m_isBusReset = false; //バスリセット +uint8_t m_senseKey = 0; // Sense key +volatile bool m_isBusReset = false; // Bus reset -byte scsi_id_mask; // 応答するSCSI IDのマスクリスト -byte m_id; // 現在応答中の SCSI-ID -byte m_lun; // 現在応答中のロジカルユニット番号 -byte m_sts; // ステータスバイト -byte m_msg; // メッセージバイト -HDDIMG *m_img; // 現在の SCSI-ID,LUNに対するHDD image -byte m_buf[BLOCKSIZE+1]; // 汎用バッファ +オーバーランフェッチ +byte scsi_id_mask; // Mask list of responding SCSI IDs +byte m_id; // Currently responding SCSI-ID +byte m_lun; // Logical unit number currently responding +byte m_sts; // Status byte +byte m_msg; // Message bytes +HDDIMG *m_img; // HDD image for current SCSI-ID, LUN +byte m_buf[BLOCKSIZE+1]; // General purpose buffer + overrun fetch int m_msc; bool m_msb[256]; /* - * データバイト to BSRRレジスタ設定値、兼パリティーテーブル + * Data byte to BSRR register setting value and parity table */ -// パリティービット生成 +// Parity bit generation #define PTY(V) (1^((V)^((V)>>1)^((V)>>2)^((V)>>3)^((V)>>4)^((V)>>5)^((V)>>6)^((V)>>7))&1) -// データバイト to BSRRレジスタ設定値変換テーブル +// Data byte to BSRR register setting value conversion table // BSRR[31:24] = DB[7:0] // BSRR[ 16] = PTY(DB) // BSRR[15: 8] = ~DB[7:0] // BSRR[ 0] = ~PTY(DB) -// DBPのセット、REQ=inactiveにする +// Set DBP, set REQ = inactive #define DBP(D) ((((((uint32_t)(D)<<8)|PTY(D))*0x00010001)^0x0000ff01)|BITMASK(vREQ)) #define DBP8(D) DBP(D),DBP(D+1),DBP(D+2),DBP(D+3),DBP(D+4),DBP(D+5),DBP(D+6),DBP(D+7) #define DBP32(D) DBP8(D),DBP8(D+8),DBP8(D+16),DBP8(D+24) -// DBのセット,DPのセット,REQ=H(inactrive) を同時に行うBSRRレジスタ制御値 +// BSRR register control value that simultaneously performs DB set, DP set, and REQ = H (inactrive) static const uint32_t db_bsrr[256]={ DBP32(0x00),DBP32(0x20),DBP32(0x40),DBP32(0x60), DBP32(0x80),DBP32(0xA0),DBP32(0xC0),DBP32(0xE0) }; -// パリティービット取得 +// Parity bit acquisition #define PARITY(DB) (db_bsrr[DB]&1) -// マクロの掃除 +// Macro cleaning #undef DBP32 #undef DBP8 //#undef DBP //#undef PTY #if USE_DB2ID_TABLE -/* DB to SCSI-ID テーブル */ +/* DB to SCSI-ID table */ static const byte db2scsiid[256]={ 0xff, 0, @@ -219,11 +219,11 @@ void onFalseInit(void); void onBusReset(void); /* - * IO読み込み. + * IO read. */ inline byte readIO(void) { - //ポート入力データレジスタ + // Port input data register uint32 ret = GPIOB->regs->IDR; byte bret = (byte)((~ret)>>8); #if READ_PARITY_CHECK @@ -235,48 +235,48 @@ inline byte readIO(void) } /* - * 初期化. - * バスの初期化、PINの向きの設定を行う + * Initialization. + * Initialize the bus and set the PIN orientation */ void setup() { - // PA15 / PB3 / PB4 が使えない - // JTAG デバッグ用に使われているからです。 + // PA15 / PB3 / PB4 Cannot be used + // JTAG Because it is used for debugging. disableDebugPorts(); - //シリアル初期化 + // Serial initialization //Serial.begin(9600); //while (!Serial); - //PINの初期化 + // PIN initialization gpio_mode(LED, GPIO_OUTPUT_OD); gpio_write(LED, low); - //GPIO(SCSI BUS)初期化 - //ポート設定レジスタ(下位) + //GPIO(SCSI BUS)Initialization + //Port setting register (lower) // GPIOB->regs->CRL |= 0x000000008; // SET INPUT W/ PUPD on PAB-PB0 - //ポート設定レジスタ(上位) + //Port setting register (upper) //GPIOB->regs->CRH = 0x88888888; // SET INPUT W/ PUPD on PB15-PB8 // GPIOB->regs->ODR = 0x0000FF00; // SET PULL-UPs on PB15-PB8 // DB,DPは入力モード SCSI_DB_INPUT() - // 入力ポート + // Input port gpio_mode(ATN, GPIO_INPUT_PU); gpio_mode(BSY, GPIO_INPUT_PU); gpio_mode(ACK, GPIO_INPUT_PU); gpio_mode(RST, GPIO_INPUT_PU); gpio_mode(SEL, GPIO_INPUT_PU); - // 出力ポート + // Output port gpio_mode(MSG, GPIO_OUTPUT_OD); gpio_mode(CD, GPIO_OUTPUT_OD); gpio_mode(REQ, GPIO_OUTPUT_OD); gpio_mode(IO, GPIO_OUTPUT_OD); - // 出力ポートはOFFにする + // Turn off the output port SCSI_TARGET_INACTIVE() -#if X1TURBO_DTC510B - // シリアル初期化 +//#if X1TURBO_DTC510B + // Serial initialization Serial.begin(9600); for(int tout=3000/200;tout;tout--) { @@ -286,9 +286,9 @@ void setup() break; } Serial.println("DTC510B HDD emulator for X1turbo"); -#endif +//#endif - //RSTピンの状態がHIGHからLOWに変わったときに発生 + //Occurs when the RST pin state changes from HIGH to LOW //attachInterrupt(PIN_MAP[RST].gpio_bit, onBusReset, FALLING); LED_ON(); @@ -299,9 +299,9 @@ void setup() onFalseInit(); } - //セクタデータオーバーランバイトの設定 + //Sector data overrun byte setting m_buf[BLOCKSIZE] = 0xff; // DB0 all off,DBP off - //HDイメージファイルオープン + //HD image file open //int totalImage = 0; scsi_id_mask = 0x00; for(int id=0;idm_fileSize = h->m_file.size(); Serial.print("Found Imagefile:"); Serial.print(file_path); - if(h->m_fileSize==0) - { - h->m_file.close(); - } - else - { - Serial.print(" / "); - Serial.print(h->m_fileSize); - Serial.print("bytes / "); - Serial.print(h->m_fileSize / 1024); - Serial.print("KiB / "); - Serial.print(h->m_fileSize / 1024 / 1024); - Serial.println("MiB"); - // 応答するIDとしてマーキング - scsi_id_mask |= 1<m_fileSize==0) + { + h->m_file.close(); + } + else + { + Serial.print(" / "); + Serial.print(h->m_fileSize); + Serial.print("bytes / "); + Serial.print(h->m_fileSize / 1024); + Serial.print("KiB / "); + Serial.print(h->m_fileSize / 1024 / 1024); + Serial.println("MiB"); + // Marked as a responsive ID + scsi_id_mask |= 1<:"); Serial.println("D:0:1:2:3:4:5:6:7:"); for(int id=0;idm_file.read(m_buf, BLOCKSIZE); #if READ_SPEED_OPTIMIZE @@ -499,18 +499,18 @@ void writeDataPhaseSD(uint32_t adds, uint32_t len) #define WAIT_ACK_INACTIVE() do{ if(m_isBusReset) return; }while(SCSI_IN(vACK)) SCSI_DB_OUTPUT() - register byte *srcptr= m_buf; // ソースバッファ - /*register*/ byte src_byte; // 送信データバイト - register const uint32_t *bsrr_tbl = db_bsrr; // BSRRに変換するテーブル - register uint32_t bsrr_val; // 出力するBSRR値(DB,DBP,REQ=ACTIVE) - register volatile uint32_t *db_dst = &(GPIOB->regs->BSRR); // 出力ポート + register byte *srcptr= m_buf; // Source buffer + /*register*/ byte src_byte; // Send data bytes + register const uint32_t *bsrr_tbl = db_bsrr; // Table to convert to BSRR + register uint32_t bsrr_val; // BSRR value to output (DB, DBP, REQ = ACTIVE) + register volatile uint32_t *db_dst = &(GPIOB->regs->BSRR); // Output port // prefetch & 1st out FETCH_SRC(); FETCH_BSRR_DB(); REQ_OFF_DB_SET(bsrr_val); // DB.set to REQ.F setup 100ns max (DTC-510B) - // ここには多少のウェイトがあったほうがいいかも + // Maybe there should be some weight here // WAIT_ACK_INACTIVE(); do{ // 0 @@ -584,8 +584,8 @@ void writeDataPhaseSD(uint32_t adds, uint32_t len) } /* - * データアウトフェーズ. - * len ブロック読み込むこむ + * Data out phase. + * len block read */ void readDataPhase(int len, byte* p) { @@ -598,8 +598,8 @@ void readDataPhase(int len, byte* p) } /* - * データアウトフェーズ. - * len ブロック読み込みながら SDカードへ書き込む。 + * Data out phase. + * Write to SD card while reading len block. */ void readDataPhaseSD(uint32_t adds, uint32_t len) { @@ -611,7 +611,7 @@ void readDataPhaseSD(uint32_t adds, uint32_t len) SCSI_OUT(vIO ,inactive) // gpio_write(IO, low); for(uint32_t i = 0; i < len; i++) { #if WRITE_SPEED_OPTIMIZE - register byte *dstptr= m_buf; + register byte *dstptr= m_buf; for(int j = 0; j < BLOCKSIZE/8; j++) { dstptr[0] = readHandshake(); dstptr[1] = readHandshake(); @@ -624,7 +624,7 @@ void readDataPhaseSD(uint32_t adds, uint32_t len) if(m_isBusReset) { return; } - dstptr+=8; + dstptr+=8; } #else for(int j = 0; j < BLOCKSIZE; j++) { @@ -633,25 +633,25 @@ void readDataPhaseSD(uint32_t adds, uint32_t len) } m_buf[j] = readHandshake(); } -#endif +#endif m_img->m_file.write(m_buf, BLOCKSIZE); } m_img->m_file.flush(); } /* - * INQUIRY コマンド処理. + * INQUIRY command processing. */ byte onInquiryCommand(byte len) { byte buf[36] = { - 0x00, //デバイスタイプ + 0x00, //device type 0x00, //RMB = 0 - 0x01, //ISO,ECMA,ANSIバージョン - 0x01, //レスポンスデータ形式 - 35 - 4, //追加データ長 + 0x01, //ISO, ECMA, ANSI version + 0x01, //Response data format + 35 - 4, //Additional data length 0, 0, //Reserve - 0x00, //サポート機能 + 0x00, //Support function 'T', 'N', 'B', ' ', ' ', ' ', ' ', ' ', 'A', 'r', 'd', 'S', 'C', 'S', 'i', 'n', 'o', ' ', ' ',' ', ' ', ' ', ' ', ' ', '0', '0', '1', '0', @@ -661,16 +661,16 @@ byte onInquiryCommand(byte len) } /* - * REQUEST SENSE コマンド処理. + * REQUEST SENSE command processing. */ void onRequestSenseCommand(byte len) { byte buf[18] = { 0x70, //CheckCondition - 0, //セグメント番号 - 0x00, //センスキー - 0, 0, 0, 0, //インフォメーション - 17 - 7 , //追加データ長 + 0, //Segment number + 0x00, //Sense key + 0, 0, 0, 0, //information + 17 - 7 , //Additional data length 0, }; buf[2] = m_senseKey; @@ -679,11 +679,11 @@ void onRequestSenseCommand(byte len) } /* - * READ CAPACITY コマンド処理. + * READ CAPACITY command processing. */ byte onReadCapacityCommand(byte pmi) { - if(!m_img) return 0x02; // イメージファイル不在 + if(!m_img) return 0x02; // Image file absent uint32_t bc = m_img->m_fileSize / BLOCKSIZE; uint32_t bl = BLOCKSIZE; @@ -696,7 +696,7 @@ byte onReadCapacityCommand(byte pmi) } /* - * READ6/10 コマンド処理. + * READ6 / 10 Command processing. */ byte onReadCommand(uint32_t adds, uint32_t len) { @@ -704,7 +704,7 @@ byte onReadCommand(uint32_t adds, uint32_t len) LOGHEXN(adds); LOGHEXN(len); - if(!m_img) return 0x02; // イメージファイル不在 + if(!m_img) return 0x02; // Image file absent gpio_write(LED, high); writeDataPhaseSD(adds, len); @@ -713,7 +713,7 @@ byte onReadCommand(uint32_t adds, uint32_t len) } /* - * WRITE6/10 コマンド処理. + * WRITE6 / 10 Command processing. */ byte onWriteCommand(uint32_t adds, uint32_t len) { @@ -721,7 +721,7 @@ byte onWriteCommand(uint32_t adds, uint32_t len) LOGHEXN(adds); LOGHEXN(len); - if(!m_img) return 0x02; // イメージファイル不在 + if(!m_img) return 0x02; // Image file absent gpio_write(LED, high); readDataPhaseSD(adds, len); @@ -730,11 +730,11 @@ byte onWriteCommand(uint32_t adds, uint32_t len) } /* - * MODE SENSE コマンド処理. + * MODE SENSE command processing. */ byte onModeSenseCommand(byte dbd, int pageCode, uint32_t len) { - if(!m_img) return 0x02; // イメージファイル不在 + if(!m_img) return 0x02; // Image file absent memset(m_buf, 0, sizeof(m_buf)); int a = 4; @@ -742,7 +742,7 @@ byte onModeSenseCommand(byte dbd, int pageCode, uint32_t len) uint32_t bc = m_img->m_fileSize / BLOCKSIZE; uint32_t bl = BLOCKSIZE; byte c[8] = { - 0,//デンシティコード + 0,//Density code bc >> 16, bc >> 8, bc, 0, //Reserve bl >> 16, bl >> 8, bl @@ -753,23 +753,23 @@ byte onModeSenseCommand(byte dbd, int pageCode, uint32_t len) } switch(pageCode) { case 0x3F: - case 0x03: //ドライブパラメータ - m_buf[a + 0] = 0x03; //ページコード - m_buf[a + 1] = 0x16; // ページ長 - m_buf[a + 11] = 0x3F;//セクタ数/トラック + case 0x03: //Drive parameters + m_buf[a + 0] = 0x03; //Page code + m_buf[a + 1] = 0x16; // Page length + m_buf[a + 11] = 0x3F;//Number of sectors / track a += 24; if(pageCode != 0x3F) { break; } - case 0x04: //ドライブパラメータ + case 0x04: //Drive parameters { uint32_t bc = m_img->m_fileSize / BLOCKSIZE; - m_buf[a + 0] = 0x04; //ページコード - m_buf[a + 1] = 0x16; // ページ長 - m_buf[a + 2] = bc >> 16;// シリンダ長 + m_buf[a + 0] = 0x04; //Page code + m_buf[a + 1] = 0x16; // Page length + m_buf[a + 2] = bc >> 16;// Cylinder length m_buf[a + 3] = bc >> 8; m_buf[a + 4] = bc; - m_buf[a + 5] = 1; //ヘッド数 + m_buf[a + 5] = 1; //Number of heads a += 24; } if(pageCode != 0x3F) { @@ -791,16 +791,16 @@ byte onModeSenseCommand(byte dbd, int pageCode, uint32_t len) #define PACKED __attribute__((packed)) typedef struct PACKED dtc500_cmd_c2_param_struct { - uint8_t StepPlusWidth; // Default is 13.6usec (11) - uint8_t StepPeriod; // Default is 3 msec.(60) - uint8_t StepMode; // Default is Bufferd (0) - uint8_t MaximumHeadAdress; // Default is 4 heads (3) - uint8_t HighCylinderAddressByte; // Default set to 0 (0) - uint8_t LowCylinderAddressByte; // Default is 153 cylinders (152) - uint8_t ReduceWrietCurrent; // Default is above Cylinder 128 (127) - uint8_t DriveType_SeekCompleteOption;// (0) - uint8_t Reserved8; // (0) - uint8_t Reserved9; // (0) + uint8_t StepPlusWidth; // Default is 13.6usec (11) + uint8_t StepPeriod; // Default is 3 msec.(60) + uint8_t StepMode; // Default is Bufferd (0) + uint8_t MaximumHeadAdress; // Default is 4 heads (3) + uint8_t HighCylinderAddressByte; // Default set to 0 (0) + uint8_t LowCylinderAddressByte; // Default is 153 cylinders (152) + uint8_t ReduceWrietCurrent; // Default is above Cylinder 128 (127) + uint8_t DriveType_SeekCompleteOption;// (0) + uint8_t Reserved8; // (0) + uint8_t Reserved9; // (0) } DTC510_CMD_C2_PARAM; static void logStrHex(const char *msg,uint32_t num) @@ -811,30 +811,30 @@ static void logStrHex(const char *msg,uint32_t num) static byte dtc510b_setDriveparameter(void) { - DTC510_CMD_C2_PARAM DriveParameter; - uint16_t maxCylinder; - uint16_t numLAD; - //uint32_t stepPulseUsec; - int StepPeriodMsec; + DTC510_CMD_C2_PARAM DriveParameter; + uint16_t maxCylinder; + uint16_t numLAD; + //uint32_t stepPulseUsec; + int StepPeriodMsec; - // receive paramter - writeDataPhase(sizeof(DriveParameter),(byte *)(&DriveParameter)); + // receive paramter + writeDataPhase(sizeof(DriveParameter),(byte *)(&DriveParameter)); - maxCylinder = - (((uint16_t)DriveParameter.HighCylinderAddressByte)<<8) | - (DriveParameter.LowCylinderAddressByte); - numLAD = maxCylinder * (DriveParameter.MaximumHeadAdress+1); - //stepPulseUsec = calcStepPulseUsec(DriveParameter.StepPlusWidth); - StepPeriodMsec = DriveParameter.StepPeriod*50; - logStrHex (" StepPlusWidth : ",DriveParameter.StepPlusWidth); - logStrHex (" StepPeriod : ",DriveParameter.StepPeriod ); - logStrHex (" StepMode : ",DriveParameter.StepMode ); - logStrHex (" MaximumHeadAdress : ",DriveParameter.MaximumHeadAdress); - logStrHex (" CylinderAddress : ",maxCylinder); - logStrHex (" ReduceWrietCurrent : ",DriveParameter.ReduceWrietCurrent); - logStrHex (" DriveType/SeekCompleteOption : ",DriveParameter.DriveType_SeekCompleteOption); + maxCylinder = + (((uint16_t)DriveParameter.HighCylinderAddressByte)<<8) | + (DriveParameter.LowCylinderAddressByte); + numLAD = maxCylinder * (DriveParameter.MaximumHeadAdress+1); + //stepPulseUsec = calcStepPulseUsec(DriveParameter.StepPlusWidth); + StepPeriodMsec = DriveParameter.StepPeriod*50; + logStrHex (" StepPlusWidth : ",DriveParameter.StepPlusWidth); + logStrHex (" StepPeriod : ",DriveParameter.StepPeriod ); + logStrHex (" StepMode : ",DriveParameter.StepMode ); + logStrHex (" MaximumHeadAdress : ",DriveParameter.MaximumHeadAdress); + logStrHex (" CylinderAddress : ",maxCylinder); + logStrHex (" ReduceWrietCurrent : ",DriveParameter.ReduceWrietCurrent); + logStrHex (" DriveType/SeekCompleteOption : ",DriveParameter.DriveType_SeekCompleteOption); logStrHex (" Maximum LAD : ",numLAD-1); - return 0; // error result + return 0; // error result } #endif @@ -865,18 +865,18 @@ void MsgOut2() } /* - * メインループ. + * Main loop. */ void loop() { //int msg = 0; m_msg = 0; - // RST=H,BSY=H,SEL=L になるまで待つ + // Wait until RST = H, BSY = H, SEL = L do {} while( SCSI_IN(vBSY) || !SCSI_IN(vSEL) || SCSI_IN(vRST)); - // BSY+ SEL- - // 応答すべきIDがドライブされていなければ次を待つ + // BSY+ SEL- + // If the ID to respond is not driven, wait for the next //byte db = readIO(); //byte scsiid = db & scsi_id_mask; byte scsiid = readIO() & scsi_id_mask; @@ -885,10 +885,10 @@ void loop() } LOGN("Selection"); m_isBusReset = false; - // セレクトされたらBSYを-にする - SCSI_BSY_ACTIVE(); // BSY出力だけON , ACTIVE にする + // Set BSY to-when selected + SCSI_BSY_ACTIVE(); // Turn only BSY output ON, ACTIVE - // 応答するTARGET-IDを求める + // Ask for a TARGET-ID to respond #if USE_DB2ID_TABLE m_id = db2scsiid[scsiid]; //if(m_id==0xff) return; @@ -898,13 +898,13 @@ void loop() //if(m_id<0) return; #endif - // SELがinactiveになるまで待つ + // Wait until SEL becomes inactive while(isHigh(gpio_read(SEL))) { if(m_isBusReset) { goto BusFree; } } - SCSI_TARGET_ACTIVE() // (BSY),REQ,MSG,CD,IO 出力をON + SCSI_TARGET_ACTIVE() // (BSY), REQ, MSG, CD, IO output turned on // if(isHigh(gpio_read(ATN))) { bool syncenable = false; @@ -928,24 +928,24 @@ void loop() // IDENTIFY if (m_msb[i] >= 0x80) { } - // 拡張メッセージ + // Extended message if (m_msb[i] == 0x01) { - // 同期転送が可能な時だけチェック + // Check only when synchronous transfer is possible if (!syncenable || m_msb[i + 2] != 0x01) { MsgIn2(0x07); break; } - // Transfer period factor(50 x 4 = 200nsに制限) + // Transfer period factor(50 x 4 = Limited to 200ns) syncperiod = m_msb[i + 3]; if (syncperiod > 50) { syncoffset = 50; } - // REQ/ACK offset(16に制限) + // REQ/ACK offset(Limited to 16) syncoffset = m_msb[i + 4]; if (syncoffset > 16) { syncoffset = 16; } - // STDR応答メッセージ生成 + // STDR response message generation MsgIn2(0x01); MsgIn2(0x03); MsgIn2(0x01); @@ -965,7 +965,7 @@ void loop() byte cmd[12]; cmd[0] = readHandshake(); if(m_isBusReset) goto BusFree; LOGHEX(cmd[0]); - // コマンド長選択、受信 + // Command length selection, reception static const int cmd_class_len[8]={6,10,10,6,6,12,6,6}; len = cmd_class_len[cmd[0] >> 5]; cmd[1] = readHandshake(); LOG(":");LOGHEX(cmd[1]); if(m_isBusReset) goto BusFree; @@ -973,25 +973,25 @@ void loop() cmd[3] = readHandshake(); LOG(":");LOGHEX(cmd[3]); if(m_isBusReset) goto BusFree; cmd[4] = readHandshake(); LOG(":");LOGHEX(cmd[4]); if(m_isBusReset) goto BusFree; cmd[5] = readHandshake(); LOG(":");LOGHEX(cmd[5]); if(m_isBusReset) goto BusFree; - // 残りのコマンド受信 + // Receive the remaining commands for(int i = 6; i < len; i++ ) { cmd[i] = readHandshake(); LOG(":"); LOGHEX(cmd[i]); if(m_isBusReset) goto BusFree; } - // LUN 確認 + // LUN confirmation m_lun = m_sts>>5; - m_sts = cmd[1]&0xe0; // ステータスバイトにLUNをプリセット - // HDD Imageの選択 - m_img = (HDDIMG *)0; // 無し + m_sts = cmd[1]&0xe0; // Preset LUN in status byte + // HDD Image selection + m_img = (HDDIMG *)0; // None if( (m_lun <= NUM_SCSILUN) ) { - m_img = &(img[m_id][m_lun]); // イメージあり + m_img = &(img[m_id][m_lun]); // There is an image if(!(m_img->m_file.isOpen())) - m_img = (HDDIMG *)0; // イメージ不在 + m_img = (HDDIMG *)0; // Image absent } - // if(!m_img) m_sts |= 0x02; // LUNに対するイメージファイル不在 + // if(!m_img) m_sts |= 0x02; // Missing image file for LUN //LOGHEX(((uint32_t)m_img)); LOG(":ID "); @@ -1103,5 +1103,5 @@ BusFree: //SCSI_OUT(vCD ,inactive) // gpio_write(CD, low); //SCSI_OUT(vIO ,inactive) // gpio_write(IO, low); //SCSI_OUT(vBSY,inactive) - SCSI_TARGET_INACTIVE() // BSY,REQ,MSG,CD,IO 出力をOFFにする + SCSI_TARGET_INACTIVE() // Turn off BSY, REQ, MSG, CD, IO output }