1
/* Copyright (c) 1996-2004, Adaptec Corporation
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions are met:
7
* - Redistributions of source code must retain the above copyright notice, this
8
* list of conditions and the following disclaimer.
9
* - Redistributions in binary form must reproduce the above copyright notice,
10
* this list of conditions and the following disclaimer in the documentation
11
* and/or other materials provided with the distribution.
12
* - Neither the name of the Adaptec Corporation nor the names of its
13
* contributors may be used to endorse or promote products derived from this
14
* software without specific prior written permission.
16
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26
* POSSIBILITY OF SUCH DAMAGE.
29
/****************************************************************************
33
*****************************************************************************
35
* File Name: ModNVRam.cpp
37
* Contributors: Lee Page
44
*****************************************************************************/
47
#include "modnvram.hpp"
51
// const int Modify_NVRam::SIZE_OF_NVRAM = 128;
56
Modify_NVRam::Modify_NVRam( int which_Hba_Num ): hba_Num( which_Hba_Num )
58
ENTER( "Modify_NVRam::Modify_NVRam( int which_Hba_Num ): hba_Num( which_Hba_Num )" );
59
// clear it in case someone wants to use it without reading first.
60
memset( &nvram_Buf, 0, sizeof( nvram_Buf ) );
64
Modify_NVRam::~Modify_NVRam()
66
ENTER( "Modify_NVRam::~Modify_NVRam()" );
71
Command::Dpt_Error Modify_NVRam::Read_NVRam_to_Buf()
73
ENTER( "Command::Dpt_Error Modify_NVRam::Read_NVRam_to_Buf()" );
75
DPT_TAG_T this_HBAs_Tag;
77
err = get_HBA_Tag( &this_HBAs_Tag );
82
err = engine->Send( MSG_GET_NV_INFO, this_HBAs_Tag );
85
if(( !err.Is_Error() )
86
&& ( engine->Extract( &nvram_Buf, sizeof( nvram_Buf ) ) == 0 ))
88
err = MSG_RTN_DATA_UNDERFLOW;
95
Command::Dpt_Error Modify_NVRam::Write_NVRam_from_Buf( bool compute_Chksum )
97
ENTER( "Command::Dpt_Error Modify_NVRam::Write_NVRam_from_Buf( bool compute_Chksum )" );
99
DPT_TAG_T this_HBAs_Tag;
101
err = get_HBA_Tag( &this_HBAs_Tag );
103
if( !err.Is_Error() && compute_Chksum )
105
nvram_Buf.computeChecksum();
107
if( !err.Is_Error() )
110
if ( engine->Insert( &nvram_Buf, sizeof( nvram_Buf ) ) == 0 )
112
err = MSG_RTN_DATA_OVERFLOW;
115
if( !err.Is_Error() )
117
err = engine->Send( MSG_SET_NV_INFO, this_HBAs_Tag );
124
Command::Dpt_Error Modify_NVRam::get_HBA_Tag( DPT_TAG_T *this_HBAs_Tag )
126
ENTER( "Command::Dpt_Error Modify_NVRam::get_HBA_Tag( DPT_TAG_T *this_HBAs_Tag )" );
130
// translate the hba index passed in into the address for this hba
131
*this_HBAs_Tag = Get_HBA_by_Index( hba_Num, &hba_Num_Found );
135
err = Command::Dpt_Error::DPT_CMD_ERR_CANT_FIND_HBA_INDEX_NVRAM;
142
dptNVRAM_S *Modify_NVRam::get_NVRam_Buf()
144
ENTER( "dptNVRAM_S *Modify_NVRam::get_NVRam_Buf()" );
146
return( &nvram_Buf );
149
/*** END OF FILE ***/