Public Member Functions | Private Member Functions | Private Attributes

bea_MicMemory Class Reference
[IVD Back-End Agent]

#include <bea_mediummemory.h>

Inheritance diagram for bea_MicMemory:
Inheritance graph
[legend]
Collaboration diagram for bea_MicMemory:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 bea_MicMemory (scsi_IO *const a_scsiIO_p)
virtual ~bea_MicMemory ()
virtual UInt16_t GetAvailable ()
virtual void Detect ()
virtual string GetSerialNumber ()
virtual string GetManufacturer ()
virtual UInt8_t GetSecondaryID ()
virtual UInt8_t GetChecksum ()
virtual void Read ()
virtual void Write ()

Private Member Functions

UInt16_t GetSize (UInt16_t a_paramCode)

Private Attributes

 log_CLASSID_m

Detailed Description

Definition at line 98 of file bea_mediummemory.h.


Constructor & Destructor Documentation

bea_MicMemory::bea_MicMemory ( scsi_IO *const   a_scsiIO_p  ) 

Definition at line 47 of file bea_micmemory.cpp.

References log_FUNC_m.

bea_MicMemory::~bea_MicMemory (  )  [virtual]

Definition at line 55 of file bea_micmemory.cpp.

References log_FUNC_m.


Member Function Documentation

void bea_MicMemory::Detect (  )  [virtual]

Implements bea_MediumMemory.

Definition at line 174 of file bea_micmemory.cpp.

References data_ModeAITConfigPage_t::ait, data_Mode_t::ait, data_ModeAIT_t::aitPage, cmn_GetEnvVariable(), dbg_LOW, dbg_NORM, GetAvailable(), ivd_BaseException::GetFriendly(), data_Mode::GetModeStruct(), scsi_IO::IOCtl(), log_DBG_m, log_FUNC_m, bea_MediumMemory::m_detected, bea_MediumMemory::m_scsiIO_p, data_ModeAITConfigPage_t::mic, and data_Mode::pg_AITCFG.

                           {
    log_FUNC_m(Detect);
    m_detected = false;
    {
        static const char* const useMIC_c("HSM_USE_MIC");
        string useMIC = cmn_GetEnvVariable(useMIC_c);
        // Is the MIC functionality enabled at all?
        if (useMIC == "no" || useMIC == "false") {
            log_DBG_m(dbg_LOW,
                useMIC_c << " = \'" << useMIC <<
                "\'. MIC functionality explicitly disabled.");
            return;
        }
    }
    {
        static const char* const useMIC_c("HSM_USE_CM");
        string useMIC = cmn_GetEnvVariable(useMIC_c);
        // Is the MIC functionality enabled at all?
        if (useMIC == "no" || useMIC == "false") {
            log_DBG_m(dbg_LOW,
                useMIC_c << " = \'" << useMIC <<
                "\'. MIC functionality explicitly disabled.");
            return;
        }
    }

    try {
        data_Mode ad(data_Mode::pg_AITCFG);
        cdb_ModeSense  aitInfo(ad);
        m_scsiIO_p->IOCtl(aitInfo);

        if ( ad.GetModeStruct().ait.aitPage.ait == 0 ) {
            log_DBG_m(dbg_NORM, "AIT tape in DDS mode. MIC will not be used. ");
        }
        else if ( ad.GetModeStruct().ait.aitPage.mic != 0 ) {
            // Was MIC detected by the tape drive?
            log_DBG_m(dbg_LOW, "MIC detected.");
            log_DBG_m(dbg_NORM, "MIC space left: " << GetAvailable());
            m_detected = true;
        }
        else {
            log_DBG_m(dbg_LOW, "MIC NOT detected.");
        }
    }
    catch (ivd_Exception &ie) {
        log_DBG_m(dbg_NORM, "MIC not detected: " << ie.GetFriendly());
    }
    catch (...) {
        log_DBG_m(dbg_NORM, "MIC not detected. Unknown exception.");
    }
}

Here is the call graph for this function:

UInt16_t bea_MicMemory::GetAvailable (  )  [virtual]

Implements bea_MediumMemory.

Definition at line 139 of file bea_micmemory.cpp.

References data_Log::GetMICAvailSize(), scsi_IO::IOCtl(), log_FUNC_m, bea_MediumMemory::m_scsiIO_p, mic_AVAILABLE_d, and data_Log::pg_MICFIXED.

Referenced by Detect().

                                     {
    log_FUNC_m(GetAvailable);

    data_Log micSize(data_Log::pg_MICFIXED, mic_AVAILABLE_d);
    cdb_LogSense logSns(micSize);
    m_scsiIO_p->IOCtl(logSns);

    return micSize.GetMICAvailSize();
}

Here is the call graph for this function:

Here is the caller graph for this function:

UInt8_t bea_MicMemory::GetChecksum (  )  [virtual]

Implements bea_MediumMemory.

Definition at line 256 of file bea_micmemory.cpp.

References data_Log::GetMICChecksum(), scsi_IO::IOCtl(), log_FUNC_m, bea_MediumMemory::m_scsiIO_p, mic_SERNUM_d, and data_Log::pg_MICFIXED.

                                  {
    log_FUNC_m(GetChecksum);

    data_Log sn(data_Log::pg_MICFIXED, mic_SERNUM_d);
    cdb_LogSense logSns(sn);
    m_scsiIO_p->IOCtl(logSns);
    return sn.GetMICChecksum();
}

Here is the call graph for this function:

string bea_MicMemory::GetManufacturer (  )  [virtual]

Implements bea_MediumMemory.

Definition at line 237 of file bea_micmemory.cpp.

References cmn_Num2Str(), data_Log::GetMICManufacturer(), scsi_IO::IOCtl(), log_FUNC_m, bea_MediumMemory::m_scsiIO_p, mic_SERNUM_d, and data_Log::pg_MICFIXED.

                                      {
    log_FUNC_m(GetManufacturer);
    data_Log sn(data_Log::pg_MICFIXED, mic_SERNUM_d);
    cdb_LogSense logSns(sn);
    m_scsiIO_p->IOCtl(logSns);
    return cmn_Num2Str(sn.GetMICManufacturer());
}

Here is the call graph for this function:

UInt8_t bea_MicMemory::GetSecondaryID (  )  [virtual]

Implements bea_MediumMemory.

Definition at line 246 of file bea_micmemory.cpp.

References data_Log::GetMICSecondaryID(), scsi_IO::IOCtl(), log_FUNC_m, bea_MediumMemory::m_scsiIO_p, mic_SERNUM_d, and data_Log::pg_MICFIXED.

                                     {
    log_FUNC_m(GetSecondaryID);

    data_Log sn(data_Log::pg_MICFIXED, mic_SERNUM_d);
    cdb_LogSense logSns(sn);
    m_scsiIO_p->IOCtl(logSns);
    return sn.GetMICSecondaryID();
}

Here is the call graph for this function:

string bea_MicMemory::GetSerialNumber (  )  [virtual]

Implements bea_MediumMemory.

Definition at line 227 of file bea_micmemory.cpp.

References data_Log::GetMICSerialNumber(), scsi_IO::IOCtl(), log_FUNC_m, bea_MediumMemory::m_scsiIO_p, mic_SERNUM_d, and data_Log::pg_MICFIXED.

                                     {
    log_FUNC_m(GetSerialNumber);

    data_Log sn(data_Log::pg_MICFIXED, mic_SERNUM_d);
    cdb_LogSense logSns(sn);
    m_scsiIO_p->IOCtl(logSns);
    return sn.GetMICSerialNumber();
}

Here is the call graph for this function:

UInt16_t bea_MicMemory::GetSize ( UInt16_t  a_paramCode  )  [private]

Definition at line 151 of file bea_micmemory.cpp.

References dbg_NORM, data_Log::GetMICNoteSize(), ie_INVALID_ARG, scsi_IO::IOCtl(), log_DBG_m, log_FUNC_m, bea_MediumMemory::m_scsiIO_p, mic_SIZEPARTNOTE_d, mic_SIZEVOLNOTE_d, and data_Log::pg_MICFIXED.

Referenced by Read().

                                                    {
    log_FUNC_m(GetSize);

    // Check valid ranges.
    if ( a_paramCode != mic_SIZEVOLNOTE_d &&
        (a_paramCode < mic_SIZEPARTNOTE_d ||
         a_paramCode > (mic_SIZEPARTNOTE_d+64)) ) {

        throw ivd_InternalError(
            ie_INVALID_ARG, "MIC size argument out of range.");
    };

    data_Log micNoteSize(data_Log::pg_MICFIXED, a_paramCode);
    cdb_LogSense logSns(micNoteSize);
    m_scsiIO_p->IOCtl(logSns);

    log_DBG_m(dbg_NORM, "MIC Note size: " << micNoteSize.GetMICNoteSize());

    return micNoteSize.GetMICNoteSize();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void bea_MicMemory::Read (  )  [virtual]

Implements bea_MediumMemory.

Definition at line 61 of file bea_micmemory.cpp.

References cmn_HexDump(), dbg_DETAIL, dbg_LOW, data_Log::GetMICNote(), data_Log::GetMICNoteLength(), bea_MediumMemory::GetNeededSpace(), GetSize(), scsi_IO::IOCtl(), log_DBG_m, log_FUNC_m, log_WRN_m, bea_MediumMemory::m_scsiIO_p, bea_MediumMemory::m_tcmmedia_vol, bea_MediumMemory::m_tcmmedium, mic_DATAVOLNOTE_d, mic_SIZEVOLNOTE_d, min, data_Log::pg_MICVARIABLE, and data_Log::UpdateMICNoteSize().

                         {
    log_FUNC_m(Read);

    if (GetSize(mic_SIZEVOLNOTE_d) == 0) {
        log_DBG_m(dbg_LOW, "Nothing in MIC. micNoteSize is 0.");
        return;
    };

    log_DBG_m(dbg_LOW, "Reading contents from MIC.");

    UInt16_t neededSpace(GetNeededSpace());
    data_Log micNote(data_Log::pg_MICVARIABLE, mic_DATAVOLNOTE_d);
    micNote.UpdateMICNoteSize(neededSpace);

    cdb_LogSense logSns(micNote);
    m_scsiIO_p->IOCtl(logSns);

    UInt16_t micNoteLen(micNote.GetMICNoteLength());

    log_DBG_m(dbg_DETAIL, "Read " << micNoteLen << " bytes. Needed " << neededSpace);

    log_DBG_m(dbg_DETAIL,
        "MIC Note contents:" << endl <<
        cmn_HexDump(micNote.GetMICNote(), micNoteLen, 16, true) );

    if (micNoteLen > neededSpace) {
        ostringstream sstr;
        log_WRN_m(
        "MIC note size does not match requested. Broken MIC? "
        << micNoteLen << " != " << neededSpace
        << " parameter: 0x" << hex << data_Log::pg_MICVARIABLE );
    }

    UInt16_t toCopy(min(neededSpace, micNoteLen));

    vector<char> contents(neededSpace, 0);

    memcpy(&(contents[0]), micNote.GetMICNote(), toCopy);

    memcpy(&m_tcmmedium, &(contents[0]), sizeof(m_tcmmedium));

    // WARNING: Vector uses contiguous memory region in memory.
    // We'll copy contents from internal buffer to m_tcmmedia_vol
    // for all volumes with one memcpy.
    memcpy(
        &(m_tcmmedia_vol[0]),
        &(contents[0]) + sizeof(m_tcmmedium),
        neededSpace - sizeof(m_tcmmedium));
}

Here is the call graph for this function:

void bea_MicMemory::Write (  )  [virtual]

Implements bea_MediumMemory.

Definition at line 113 of file bea_micmemory.cpp.

References bea_MediumMemory::GetNeededSpace(), scsi_IO::IOCtl(), log_FUNC_m, bea_MediumMemory::m_scsiIO_p, bea_MediumMemory::m_tcmmedia_vol, bea_MediumMemory::m_tcmmedium, mic_DATAVOLNOTE_d, data_Log::pg_MICVARIABLE, and data_Log::SetMICNote().

                          {

    log_FUNC_m(Write);

    vector<char> contents(GetNeededSpace(), 0);
    memcpy(&(contents[0]), &m_tcmmedium, sizeof(m_tcmmedium));

    // WARNING: Vector uses contiguous memory region in memory.
    // We'll copy contents to internal buffer to m_tcmmedia_vol
    // for all volumes with one memcpy.
    memcpy(
        &(contents[0]) + sizeof(m_tcmmedium),
        &(m_tcmmedia_vol[0]),
        GetNeededSpace() - sizeof(m_tcmmedium));

    data_Log micNote(data_Log::pg_MICVARIABLE, mic_DATAVOLNOTE_d);

    micNote.SetMICNote(&(contents[0]), GetNeededSpace());
    cdb_LogSelect logSel(micNote);

    m_scsiIO_p->IOCtl(logSel);
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from bea_MediumMemory.

Definition at line 116 of file bea_mediummemory.h.


The documentation for this class was generated from the following files: