~ubuntu-branches/ubuntu/intrepid/raidutils/intrepid

« back to all changes in this revision

Viewing changes to raidutil/modnvram.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Barak Pearlmutter
  • Date: 2004-05-18 11:33:42 UTC
  • Revision ID: james.westby@ubuntu.com-20040518113342-tyqavmso5q351xi2
Tags: upstream-0.0.4
ImportĀ upstreamĀ versionĀ 0.0.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (c) 1996-2004, Adaptec Corporation
 
2
 * All rights reserved.
 
3
 *
 
4
 * Redistribution and use in source and binary forms, with or without
 
5
 * modification, are permitted provided that the following conditions are met:
 
6
 *
 
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.
 
15
 *
 
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.
 
27
 */
 
28
 
 
29
/****************************************************************************
 
30
*
 
31
* Created:  8/4/98
 
32
*
 
33
*****************************************************************************
 
34
*
 
35
* File Name:            ModNVRam.cpp
 
36
* Module:
 
37
* Contributors:         Lee Page
 
38
* Description:
 
39
* Version Control:
 
40
*
 
41
* $Revision: 6 $
 
42
* $NoKeywords: $
 
43
* $Log: $
 
44
*****************************************************************************/
 
45
 
 
46
/*** INCLUDES ***/
 
47
#include "modnvram.hpp"
 
48
/*** CONSTANTS ***/
 
49
/*** TYPES ***/
 
50
/*** STATIC DATA ***/
 
51
// const int    Modify_NVRam::SIZE_OF_NVRAM     = 128;
 
52
/*** MACROS ***/
 
53
/*** PROTOTYPES ***/
 
54
/*** FUNCTIONS ***/
 
55
 
 
56
Modify_NVRam::Modify_NVRam( int which_Hba_Num ): hba_Num( which_Hba_Num )
 
57
        {
 
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 ) );
 
61
        EXIT();
 
62
        }
 
63
 
 
64
Modify_NVRam::~Modify_NVRam()
 
65
        {
 
66
        ENTER( "Modify_NVRam::~Modify_NVRam()" );
 
67
 
 
68
        EXIT();
 
69
        }
 
70
 
 
71
Command::Dpt_Error              Modify_NVRam::Read_NVRam_to_Buf()
 
72
        {
 
73
        ENTER( "Command::Dpt_Error              Modify_NVRam::Read_NVRam_to_Buf()" );
 
74
        Dpt_Error       err;
 
75
        DPT_TAG_T       this_HBAs_Tag;
 
76
 
 
77
        err     = get_HBA_Tag( &this_HBAs_Tag );
 
78
 
 
79
        if( !err.Is_Error() )
 
80
                {
 
81
                engine->Reset();
 
82
                err     = engine->Send( MSG_GET_NV_INFO, this_HBAs_Tag );
 
83
                }
 
84
 
 
85
        if(( !err.Is_Error() )
 
86
         && ( engine->Extract( &nvram_Buf, sizeof( nvram_Buf ) ) == 0 ))
 
87
                {
 
88
                        err = MSG_RTN_DATA_UNDERFLOW;
 
89
                }
 
90
 
 
91
        EXIT();
 
92
        return( err );
 
93
        }
 
94
 
 
95
Command::Dpt_Error      Modify_NVRam::Write_NVRam_from_Buf( bool compute_Chksum )
 
96
        {
 
97
        ENTER( "Command::Dpt_Error      Modify_NVRam::Write_NVRam_from_Buf( bool compute_Chksum )" );
 
98
        Dpt_Error       err;
 
99
        DPT_TAG_T       this_HBAs_Tag;
 
100
 
 
101
        err     = get_HBA_Tag( &this_HBAs_Tag );
 
102
 
 
103
        if( !err.Is_Error() && compute_Chksum )
 
104
                {
 
105
                nvram_Buf.computeChecksum();
 
106
                }
 
107
        if( !err.Is_Error() )
 
108
                {
 
109
                engine->Reset();
 
110
                if ( engine->Insert( &nvram_Buf, sizeof( nvram_Buf ) ) == 0 )
 
111
                        {
 
112
                        err = MSG_RTN_DATA_OVERFLOW;
 
113
                        }
 
114
                }
 
115
        if( !err.Is_Error() )
 
116
                {
 
117
                err     = engine->Send( MSG_SET_NV_INFO, this_HBAs_Tag );
 
118
                }
 
119
 
 
120
        EXIT();
 
121
        return( err );
 
122
        }
 
123
 
 
124
Command::Dpt_Error       Modify_NVRam::get_HBA_Tag( DPT_TAG_T *this_HBAs_Tag )
 
125
        {
 
126
        ENTER( "Command::Dpt_Error       Modify_NVRam::get_HBA_Tag( DPT_TAG_T *this_HBAs_Tag )" );
 
127
        bool            hba_Num_Found;
 
128
        Dpt_Error       err;
 
129
 
 
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 );
 
132
 
 
133
        if( !hba_Num_Found )
 
134
                {
 
135
                err     = Command::Dpt_Error::DPT_CMD_ERR_CANT_FIND_HBA_INDEX_NVRAM;
 
136
                }
 
137
 
 
138
        EXIT();
 
139
        return( err );
 
140
        }
 
141
 
 
142
dptNVRAM_S      *Modify_NVRam::get_NVRam_Buf()
 
143
        {
 
144
        ENTER( "dptNVRAM_S      *Modify_NVRam::get_NVRam_Buf()" );
 
145
        EXIT();
 
146
        return( &nvram_Buf );
 
147
        }
 
148
 
 
149
/*** END OF FILE ***/