mirror of
https://github.com/thewesker/RASCSI.git
synced 2025-12-22 13:21:17 -05:00
Comment changes only - translated to english
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
//
|
//
|
||||||
// Powered by XM6 TypeG Technology.
|
// Powered by XM6 TypeG Technology.
|
||||||
// Copyright (C) 2016-2020 GIMONS
|
// Copyright (C) 2016-2020 GIMONS
|
||||||
// [ HDDダンプユーティリティ(イニシーエタモード) ]
|
// [ HDD dump utility (initiator mode) ]
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -17,46 +17,46 @@
|
|||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// 定数宣言
|
// Constant Declaration
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
#define BUFSIZE 1024 * 64 // 64KBぐらいかなぁ
|
#define BUFSIZE 1024 * 64 // Buffer size of about 64KB
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// 変数宣言
|
// 変数宣言
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
GPIOBUS bus; // バス
|
GPIOBUS bus; // Bus
|
||||||
int targetid; // ターゲットデバイスID
|
int targetid; // Target ID
|
||||||
int boardid; // ボードID(自身のID)
|
int boardid; // Board ID (own ID)
|
||||||
Filepath hdsfile; // HDSファイル
|
Filepath hdsfile; // HDS file
|
||||||
BOOL restore; // リストアフラグ
|
BOOL restore; // Restore flag
|
||||||
BYTE buffer[BUFSIZE]; // ワークバッファ
|
BYTE buffer[BUFSIZE]; // Work Buffer
|
||||||
int result; // 結果コード
|
int result; // Result Code
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// 関数宣言
|
// Cleanup() Function declaration
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
void Cleanup();
|
void Cleanup();
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// シグナル処理
|
// Signal processing
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
void KillHandler(int sig)
|
void KillHandler(int sig)
|
||||||
{
|
{
|
||||||
// 停止指示
|
// Stop running
|
||||||
Cleanup();
|
Cleanup();
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// バナー出力
|
// Banner Output
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
BOOL Banner(int argc, char* argv[])
|
BOOL Banner(int argc, char* argv[])
|
||||||
@@ -81,12 +81,12 @@ BOOL Banner(int argc, char* argv[])
|
|||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// 初期化
|
// Initialization
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
BOOL Init()
|
BOOL Init()
|
||||||
{
|
{
|
||||||
// 割り込みハンドラ設定
|
// Interrupt handler setting
|
||||||
if (signal(SIGINT, KillHandler) == SIG_ERR) {
|
if (signal(SIGINT, KillHandler) == SIG_ERR) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@@ -97,12 +97,12 @@ BOOL Init()
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// GPIO初期化
|
// GPIO Initialization
|
||||||
if (!bus.Init(BUS::INITIATOR)) {
|
if (!bus.Init(BUS::INITIATOR)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ワーク初期化
|
// Work Intitialization
|
||||||
targetid = -1;
|
targetid = -1;
|
||||||
boardid = 7;
|
boardid = 7;
|
||||||
restore = FALSE;
|
restore = FALSE;
|
||||||
@@ -112,29 +112,29 @@ BOOL Init()
|
|||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// クリーンアップ
|
// Cleanup
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
void Cleanup()
|
void Cleanup()
|
||||||
{
|
{
|
||||||
// バスをクリーンアップ
|
// Cleanup the bus
|
||||||
bus.Cleanup();
|
bus.Cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// リセット
|
// Reset
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
void Reset()
|
void Reset()
|
||||||
{
|
{
|
||||||
// バス信号線をリセット
|
// Reset the bus signal line
|
||||||
bus.Reset();
|
bus.Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// 引数処理
|
// Argument processing
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
BOOL ParseArgument(int argc, char* argv[])
|
BOOL ParseArgument(int argc, char* argv[])
|
||||||
@@ -142,10 +142,10 @@ BOOL ParseArgument(int argc, char* argv[])
|
|||||||
int opt;
|
int opt;
|
||||||
char *file;
|
char *file;
|
||||||
|
|
||||||
// 初期化
|
// Initialization
|
||||||
file = NULL;
|
file = NULL;
|
||||||
|
|
||||||
// 引数解析
|
// Argument Parsing
|
||||||
opterr = 0;
|
opterr = 0;
|
||||||
while ((opt = getopt(argc, argv, "i:b:f:r")) != -1) {
|
while ((opt = getopt(argc, argv, "i:b:f:r")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
@@ -167,28 +167,28 @@ BOOL ParseArgument(int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TARGET IDチェック
|
// TARGET ID check
|
||||||
if (targetid < 0 || targetid > 7) {
|
if (targetid < 0 || targetid > 7) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Error : Invalid target id range\n");
|
"Error : Invalid target id range\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// BOARD IDチェック
|
// BOARD ID check
|
||||||
if (boardid < 0 || boardid > 7) {
|
if (boardid < 0 || boardid > 7) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Error : Invalid board id range\n");
|
"Error : Invalid board id range\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TARGETとBOARDのID重複チェック
|
// Target and Board ID duplication check
|
||||||
if (targetid == boardid) {
|
if (targetid == boardid) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Error : Invalid target or board id\n");
|
"Error : Invalid target or board id\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ファイルチェック
|
// File Check
|
||||||
if (!file) {
|
if (!file) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Error : Invalid file path\n");
|
"Error : Invalid file path\n");
|
||||||
@@ -202,14 +202,14 @@ BOOL ParseArgument(int argc, char* argv[])
|
|||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// フェーズ待ち
|
// Wait Phase
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
BOOL WaitPhase(BUS::phase_t phase)
|
BOOL WaitPhase(BUS::phase_t phase)
|
||||||
{
|
{
|
||||||
DWORD now;
|
DWORD now;
|
||||||
|
|
||||||
// タイムアウト(3000ms)
|
// Timeout (3000ms)
|
||||||
now = SysTimer::GetTimerLow();
|
now = SysTimer::GetTimerLow();
|
||||||
while ((SysTimer::GetTimerLow() - now) < 3 * 1000 * 1000) {
|
while ((SysTimer::GetTimerLow() - now) < 3 * 1000 * 1000) {
|
||||||
bus.Aquire();
|
bus.Aquire();
|
||||||
@@ -223,18 +223,18 @@ BOOL WaitPhase(BUS::phase_t phase)
|
|||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// バスフリーフェーズ実行
|
// Bus Free Phase
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
void BusFree()
|
void BusFree()
|
||||||
{
|
{
|
||||||
// バスリセット
|
// Bus Reset
|
||||||
bus.Reset();
|
bus.Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// セレクションフェーズ実行
|
// Selection Phase
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
BOOL Selection(int id)
|
BOOL Selection(int id)
|
||||||
@@ -242,14 +242,14 @@ BOOL Selection(int id)
|
|||||||
BYTE data;
|
BYTE data;
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
// ID設定とSELアサート
|
// ID setting and SEL assert
|
||||||
data = 0;
|
data = 0;
|
||||||
data |= (1 << boardid);
|
data |= (1 << boardid);
|
||||||
data |= (1 << id);
|
data |= (1 << id);
|
||||||
bus.SetDAT(data);
|
bus.SetDAT(data);
|
||||||
bus.SetSEL(TRUE);
|
bus.SetSEL(TRUE);
|
||||||
|
|
||||||
// BSYを待つ
|
// wait for busy
|
||||||
count = 10000;
|
count = 10000;
|
||||||
do {
|
do {
|
||||||
usleep(20);
|
usleep(20);
|
||||||
@@ -259,127 +259,128 @@ BOOL Selection(int id)
|
|||||||
}
|
}
|
||||||
} while (count--);
|
} while (count--);
|
||||||
|
|
||||||
// SELネゲート
|
// SEL negate
|
||||||
bus.SetSEL(FALSE);
|
bus.SetSEL(FALSE);
|
||||||
|
|
||||||
// ターゲットがビジー状態なら成功
|
// Success if the target is busy
|
||||||
return bus.GetBSY();
|
return bus.GetBSY();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// コマンドフェーズ実行
|
// Command Phase
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
BOOL Command(BYTE *buf, int length)
|
BOOL Command(BYTE *buf, int length)
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
// フェーズ待ち
|
// Waiting for Phase
|
||||||
if (!WaitPhase(BUS::command)) {
|
if (!WaitPhase(BUS::command)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// コマンド送信
|
// Send Command
|
||||||
count = bus.SendHandShake(buf, length);
|
count = bus.SendHandShake(buf, length);
|
||||||
|
|
||||||
// 送信結果が依頼数と同じなら成功
|
// Success if the transmission result is the same as the number
|
||||||
|
// of requests
|
||||||
if (count == length) {
|
if (count == length) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 送信エラー
|
// Return error
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// データインフェーズ実行
|
// Data in phase
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
int DataIn(BYTE *buf, int length)
|
int DataIn(BYTE *buf, int length)
|
||||||
{
|
{
|
||||||
// フェーズ待ち
|
// Wait for phase
|
||||||
if (!WaitPhase(BUS::datain)) {
|
if (!WaitPhase(BUS::datain)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// データ受信
|
// Data reception
|
||||||
return bus.ReceiveHandShake(buf, length);
|
return bus.ReceiveHandShake(buf, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// データアウトフェーズ実行
|
// Data out phase
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
int DataOut(BYTE *buf, int length)
|
int DataOut(BYTE *buf, int length)
|
||||||
{
|
{
|
||||||
// フェーズ待ち
|
// Wait for phase
|
||||||
if (!WaitPhase(BUS::dataout)) {
|
if (!WaitPhase(BUS::dataout)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// データ受信
|
// Data transmission
|
||||||
return bus.SendHandShake(buf, length);
|
return bus.SendHandShake(buf, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// ステータスフェーズ実行
|
// Status Phase
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
int Status()
|
int Status()
|
||||||
{
|
{
|
||||||
BYTE buf[256];
|
BYTE buf[256];
|
||||||
|
|
||||||
// フェーズ待ち
|
// Wait for phase
|
||||||
if (!WaitPhase(BUS::status)) {
|
if (!WaitPhase(BUS::status)) {
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// データ受信
|
// Data reception
|
||||||
if (bus.ReceiveHandShake(buf, 1) == 1) {
|
if (bus.ReceiveHandShake(buf, 1) == 1) {
|
||||||
return (int)buf[0];
|
return (int)buf[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 受信エラー
|
// Return error
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// メッセージインフェーズ実行
|
// Message in phase
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
int MessageIn()
|
int MessageIn()
|
||||||
{
|
{
|
||||||
BYTE buf[256];
|
BYTE buf[256];
|
||||||
|
|
||||||
// フェーズ待ち
|
// Wait for phase
|
||||||
if (!WaitPhase(BUS::msgin)) {
|
if (!WaitPhase(BUS::msgin)) {
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// データ受信
|
// Data reception
|
||||||
if (bus.ReceiveHandShake(buf, 1) == 1) {
|
if (bus.ReceiveHandShake(buf, 1) == 1) {
|
||||||
return (int)buf[0];
|
return (int)buf[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 受信エラー
|
// Return error
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// TEST UNIT READY実行
|
// TEST UNIT READY
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
int TestUnitReady(int id)
|
int TestUnitReady(int id)
|
||||||
{
|
{
|
||||||
BYTE cmd[256];
|
BYTE cmd[256];
|
||||||
|
|
||||||
// 結果コード初期化
|
// Result code initialization
|
||||||
result = 0;
|
result = 0;
|
||||||
|
|
||||||
// SELECTION
|
// SELECTION
|
||||||
@@ -409,7 +410,7 @@ int TestUnitReady(int id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
// バスフリー
|
// Bus free
|
||||||
BusFree();
|
BusFree();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -417,7 +418,7 @@ exit:
|
|||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// REQUEST SENSE実行
|
// REQUEST SENSE
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
int RequestSense(int id, BYTE *buf)
|
int RequestSense(int id, BYTE *buf)
|
||||||
@@ -425,7 +426,7 @@ int RequestSense(int id, BYTE *buf)
|
|||||||
BYTE cmd[256];
|
BYTE cmd[256];
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
// 結果コード初期化
|
// Result code initialization
|
||||||
result = 0;
|
result = 0;
|
||||||
count = 0;
|
count = 0;
|
||||||
|
|
||||||
@@ -465,10 +466,10 @@ int RequestSense(int id, BYTE *buf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
// バスフリー
|
// Bus Free
|
||||||
BusFree();
|
BusFree();
|
||||||
|
|
||||||
// 成功であれば転送数を返す
|
// Returns the number of transfers if successful
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
@@ -478,7 +479,7 @@ exit:
|
|||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// MODE SENSE実行
|
// MODE SENSE
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
int ModeSense(int id, BYTE *buf)
|
int ModeSense(int id, BYTE *buf)
|
||||||
@@ -486,7 +487,7 @@ int ModeSense(int id, BYTE *buf)
|
|||||||
BYTE cmd[256];
|
BYTE cmd[256];
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
// 結果コード初期化
|
// Result code initialization
|
||||||
result = 0;
|
result = 0;
|
||||||
count = 0;
|
count = 0;
|
||||||
|
|
||||||
@@ -527,10 +528,10 @@ int ModeSense(int id, BYTE *buf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
// バスフリー
|
// Bus free
|
||||||
BusFree();
|
BusFree();
|
||||||
|
|
||||||
// 成功であれば転送数を返す
|
// Returns the number of transfers if successful
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
@@ -540,7 +541,7 @@ exit:
|
|||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// INQUIRY実行
|
// INQUIRY
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
int Inquiry(int id, BYTE *buf)
|
int Inquiry(int id, BYTE *buf)
|
||||||
@@ -548,7 +549,7 @@ int Inquiry(int id, BYTE *buf)
|
|||||||
BYTE cmd[256];
|
BYTE cmd[256];
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
// 結果コード初期化
|
// Result code initialization
|
||||||
result = 0;
|
result = 0;
|
||||||
count = 0;
|
count = 0;
|
||||||
|
|
||||||
@@ -588,10 +589,10 @@ int Inquiry(int id, BYTE *buf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
// バスフリー
|
// Bus free
|
||||||
BusFree();
|
BusFree();
|
||||||
|
|
||||||
// 成功であれば転送数を返す
|
// Returns the number of transfers if successful
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
@@ -601,7 +602,7 @@ exit:
|
|||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// READ CAPACITY実行
|
// READ CAPACITY
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
int ReadCapacity(int id, BYTE *buf)
|
int ReadCapacity(int id, BYTE *buf)
|
||||||
@@ -609,7 +610,7 @@ int ReadCapacity(int id, BYTE *buf)
|
|||||||
BYTE cmd[256];
|
BYTE cmd[256];
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
// 結果コード初期化
|
// Result code initialization
|
||||||
result = 0;
|
result = 0;
|
||||||
count = 0;
|
count = 0;
|
||||||
|
|
||||||
@@ -648,10 +649,10 @@ int ReadCapacity(int id, BYTE *buf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
// バスフリー
|
// Bus free
|
||||||
BusFree();
|
BusFree();
|
||||||
|
|
||||||
// 成功であれば転送数を返す
|
// Returns the number of transfers if successful
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
@@ -661,7 +662,7 @@ exit:
|
|||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// READ10実行
|
// READ10
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
int Read10(int id, DWORD bstart, DWORD blength, DWORD length, BYTE *buf)
|
int Read10(int id, DWORD bstart, DWORD blength, DWORD length, BYTE *buf)
|
||||||
@@ -669,7 +670,7 @@ int Read10(int id, DWORD bstart, DWORD blength, DWORD length, BYTE *buf)
|
|||||||
BYTE cmd[256];
|
BYTE cmd[256];
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
// 結果コード初期化
|
// Result code initialization
|
||||||
result = 0;
|
result = 0;
|
||||||
count = 0;
|
count = 0;
|
||||||
|
|
||||||
@@ -713,10 +714,10 @@ int Read10(int id, DWORD bstart, DWORD blength, DWORD length, BYTE *buf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
// バスフリー
|
// Bus free
|
||||||
BusFree();
|
BusFree();
|
||||||
|
|
||||||
// 成功であれば転送数を返す
|
// Returns the number of transfers if successful
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
@@ -726,7 +727,7 @@ exit:
|
|||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// WRITE10実行
|
// WRITE10
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
int Write10(int id, DWORD bstart, DWORD blength, DWORD length, BYTE *buf)
|
int Write10(int id, DWORD bstart, DWORD blength, DWORD length, BYTE *buf)
|
||||||
@@ -734,7 +735,7 @@ int Write10(int id, DWORD bstart, DWORD blength, DWORD length, BYTE *buf)
|
|||||||
BYTE cmd[256];
|
BYTE cmd[256];
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
// 結果コード初期化
|
// Result code initialization
|
||||||
result = 0;
|
result = 0;
|
||||||
count = 0;
|
count = 0;
|
||||||
|
|
||||||
@@ -778,10 +779,10 @@ int Write10(int id, DWORD bstart, DWORD blength, DWORD length, BYTE *buf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
// バスフリー
|
// Bus free
|
||||||
BusFree();
|
BusFree();
|
||||||
|
|
||||||
// 成功であれば転送数を返す
|
// Returns the number of transfers if successful
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
@@ -791,7 +792,7 @@ exit:
|
|||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// 主処理
|
// Main process
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
@@ -808,32 +809,32 @@ int main(int argc, char* argv[])
|
|||||||
Fileio::OpenMode omode;
|
Fileio::OpenMode omode;
|
||||||
off64_t size;
|
off64_t size;
|
||||||
|
|
||||||
// バナー出力
|
// Banner output
|
||||||
if (!Banner(argc, argv)) {
|
if (!Banner(argc, argv)) {
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 初期化
|
// Initialization
|
||||||
if (!Init()) {
|
if (!Init()) {
|
||||||
fprintf(stderr, "Error : Initializing\n");
|
fprintf(stderr, "Error : Initializing. Are you root?\n");
|
||||||
|
|
||||||
// 恐らくrootでは無い?
|
// Probably not root
|
||||||
exit(EPERM);
|
exit(EPERM);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 構築
|
// Prase Argument
|
||||||
if (!ParseArgument(argc, argv)) {
|
if (!ParseArgument(argc, argv)) {
|
||||||
// クリーンアップ
|
// Cleanup
|
||||||
Cleanup();
|
Cleanup();
|
||||||
|
|
||||||
// 引数エラーで終了
|
// Exit with invalid argument error
|
||||||
exit(EINVAL);
|
exit(EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// リセット
|
// Reset the SCSI bus
|
||||||
Reset();
|
Reset();
|
||||||
|
|
||||||
// ファイルオープン
|
// File Open
|
||||||
if (restore) {
|
if (restore) {
|
||||||
omode = Fileio::ReadOnly;
|
omode = Fileio::ReadOnly;
|
||||||
} else {
|
} else {
|
||||||
@@ -842,20 +843,20 @@ int main(int argc, char* argv[])
|
|||||||
if (!fio.Open(hdsfile.GetPath(), omode)) {
|
if (!fio.Open(hdsfile.GetPath(), omode)) {
|
||||||
fprintf(stderr, "Error : Can't open hds file\n");
|
fprintf(stderr, "Error : Can't open hds file\n");
|
||||||
|
|
||||||
// クリーンアップ
|
// Cleanup
|
||||||
Cleanup();
|
Cleanup();
|
||||||
exit(EPERM);
|
exit(EPERM);
|
||||||
}
|
}
|
||||||
|
|
||||||
// バスフリー
|
// Bus free
|
||||||
BusFree();
|
BusFree();
|
||||||
|
|
||||||
// RESETシグナル発行
|
// Assert reset signal
|
||||||
bus.SetRST(TRUE);
|
bus.SetRST(TRUE);
|
||||||
usleep(1000);
|
usleep(1000);
|
||||||
bus.SetRST(FALSE);
|
bus.SetRST(FALSE);
|
||||||
|
|
||||||
// ダンプ開始
|
// Start dump
|
||||||
printf("TARGET ID : %d\n", targetid);
|
printf("TARGET ID : %d\n", targetid);
|
||||||
printf("BORAD ID : %d\n", boardid);
|
printf("BORAD ID : %d\n", boardid);
|
||||||
|
|
||||||
@@ -880,7 +881,7 @@ int main(int argc, char* argv[])
|
|||||||
goto cleanup_exit;
|
goto cleanup_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// INQUIRYの情報を表示
|
// Display INQUIRY information
|
||||||
memset(str, 0x00, sizeof(str));
|
memset(str, 0x00, sizeof(str));
|
||||||
memcpy(str, &buffer[8], 8);
|
memcpy(str, &buffer[8], 8);
|
||||||
printf("Vendor : %s\n", str);
|
printf("Vendor : %s\n", str);
|
||||||
@@ -891,14 +892,14 @@ int main(int argc, char* argv[])
|
|||||||
memcpy(str, &buffer[32], 4);
|
memcpy(str, &buffer[32], 4);
|
||||||
printf("Revison : %s\n", str);
|
printf("Revison : %s\n", str);
|
||||||
|
|
||||||
// 容量取得
|
// Get drive capacity
|
||||||
count = ReadCapacity(targetid, buffer);
|
count = ReadCapacity(targetid, buffer);
|
||||||
if (count < 0) {
|
if (count < 0) {
|
||||||
fprintf(stderr, "READ CAPACITY ERROR %d\n", count);
|
fprintf(stderr, "READ CAPACITY ERROR %d\n", count);
|
||||||
goto cleanup_exit;
|
goto cleanup_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ブロックサイズとブロック数の表示
|
// Display block size and number of blocks
|
||||||
bsiz =
|
bsiz =
|
||||||
(buffer[4] << 24) | (buffer[5] << 16) |
|
(buffer[4] << 24) | (buffer[5] << 16) |
|
||||||
(buffer[6] << 8) | buffer[7];
|
(buffer[6] << 8) | buffer[7];
|
||||||
@@ -912,7 +913,7 @@ int main(int argc, char* argv[])
|
|||||||
(int)(bsiz * bnum / 1024 / 1024),
|
(int)(bsiz * bnum / 1024 / 1024),
|
||||||
(int)(bsiz * bnum));
|
(int)(bsiz * bnum));
|
||||||
|
|
||||||
// リストアファイルサイズの取得
|
// Get the restore file size
|
||||||
if (restore) {
|
if (restore) {
|
||||||
size = fio.GetFileSize();
|
size = fio.GetFileSize();
|
||||||
printf("Restore file size : %d bytes", (int)size);
|
printf("Restore file size : %d bytes", (int)size);
|
||||||
@@ -925,7 +926,7 @@ int main(int argc, char* argv[])
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// バッファサイズ毎にダンプする
|
// Dump by buffer size
|
||||||
duni = BUFSIZE;
|
duni = BUFSIZE;
|
||||||
duni /= bsiz;
|
duni /= bsiz;
|
||||||
dsiz = BUFSIZE;
|
dsiz = BUFSIZE;
|
||||||
@@ -973,7 +974,7 @@ int main(int argc, char* argv[])
|
|||||||
printf("\033[0K");
|
printf("\033[0K");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 容量上の端数処理
|
// Rounding on capacity
|
||||||
dnum = bnum % duni;
|
dnum = bnum % duni;
|
||||||
dsiz = dnum * bsiz;
|
dsiz = dnum * bsiz;
|
||||||
if (dnum > 0) {
|
if (dnum > 0) {
|
||||||
@@ -988,16 +989,16 @@ int main(int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 完了メッセージ
|
// Completion Message
|
||||||
printf("%3d%%(%7d/%7d)\n", 100, (int)bnum, (int)bnum);
|
printf("%3d%%(%7d/%7d)\n", 100, (int)bnum, (int)bnum);
|
||||||
|
|
||||||
cleanup_exit:
|
cleanup_exit:
|
||||||
// ファイルクローズ
|
// File close
|
||||||
fio.Close();
|
fio.Close();
|
||||||
|
|
||||||
// クリーンアップ
|
// Cleanup
|
||||||
Cleanup();
|
Cleanup();
|
||||||
|
|
||||||
// 終了
|
// end
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user