2 * Copyright (C) 2005-2008 by Pieter Palmers
4 * This file is part of FFADO
5 * FFADO = Free Firewire (pro-)audio drivers for linux
7 * FFADO is based upon FreeBoB
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 2 of the License, or
12 * (at your option) version 3 of the License.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 #include "efc_cmds_flash.h"
27 #include "libutil/ByteSwap.h"
34 EfcFlashEraseCmd::EfcFlashEraseCmd()
35 : EfcCmd(EFC_CAT_FLASH
, EFC_CMD_FLASH_ERASE
)
36 , m_address ( 0xFFFFFFFF )
41 EfcFlashEraseCmd::serialize( Util::Cmd::IOSSerialize
& se
)
45 // the length should be specified before
46 // the header is serialized
47 m_length
=EFC_HEADER_LENGTH_QUADLETS
+ 1;
49 result
&= EfcCmd::serialize ( se
);
50 result
&= se
.write(CondSwapToBus32(m_address
), "Address" );
56 EfcFlashEraseCmd::deserialize( Util::Cmd::IISDeserialize
& de
)
60 result
&= EfcCmd::deserialize ( de
);
66 EfcFlashEraseCmd::showEfcCmd()
69 debugOutput(DEBUG_LEVEL_NORMAL
, "EFC Flash Erase:\n");
70 debugOutput(DEBUG_LEVEL_NORMAL
, " Address : %u\n", m_address
);
74 EfcFlashReadCmd::EfcFlashReadCmd()
75 : EfcCmd(EFC_CAT_FLASH
, EFC_CMD_FLASH_READ
)
76 , m_address ( 0xFFFFFFFF )
82 EfcFlashReadCmd::serialize( Util::Cmd::IOSSerialize
& se
)
86 // the length should be specified before
87 // the header is serialized
88 m_length
=EFC_HEADER_LENGTH_QUADLETS
+2;
90 result
&= EfcCmd::serialize ( se
);
92 result
&= se
.write(CondSwapToBus32(m_address
), "Address" );
93 result
&= se
.write(CondSwapToBus32(m_nb_quadlets
), "Length (quadlets)" );
99 EfcFlashReadCmd::deserialize( Util::Cmd::IISDeserialize
& de
)
103 result
&= EfcCmd::deserialize ( de
);
105 EFC_DESERIALIZE_AND_SWAP(de
, &m_address
, result
);
106 EFC_DESERIALIZE_AND_SWAP(de
, &m_nb_quadlets
, result
);
107 if (m_nb_quadlets
> EFC_FLASH_SIZE_QUADS
) {
108 debugError("Too much quadlets returned: %u\n", m_nb_quadlets
);
111 for (unsigned int i
=0; i
< m_nb_quadlets
; i
++) {
112 EFC_DESERIALIZE_AND_SWAP(de
, &m_data
[i
], result
);
118 EfcFlashReadCmd::showEfcCmd()
120 EfcCmd::showEfcCmd();
121 debugOutput(DEBUG_LEVEL_NORMAL
, "EFC Flash Read:\n");
122 debugOutput(DEBUG_LEVEL_NORMAL
, " Address : %u\n", m_address
);
123 debugOutput(DEBUG_LEVEL_NORMAL
, " Length (quadlets) : %u\n", m_nb_quadlets
);
124 debugOutput(DEBUG_LEVEL_NORMAL
, " Data : \n");
125 for (unsigned int i
=0; i
< m_nb_quadlets
; i
++) {
126 debugOutput(DEBUG_LEVEL_NORMAL
, " %08X \n", m_data
[i
]);
131 EfcFlashWriteCmd::EfcFlashWriteCmd()
132 : EfcCmd(EFC_CAT_FLASH
, EFC_CMD_FLASH_WRITE
)
133 , m_address ( 0xFFFFFFFF )
134 , m_nb_quadlets ( 0 )
139 EfcFlashWriteCmd::serialize( Util::Cmd::IOSSerialize
& se
)
143 if (m_nb_quadlets
> EFC_FLASH_SIZE_QUADS
) {
144 debugError("Too much quadlets to write: %u\n", m_nb_quadlets
);
148 // the length should be specified before
149 // the header is serialized
150 m_length
=EFC_HEADER_LENGTH_QUADLETS
+2+m_nb_quadlets
;
152 result
&= EfcCmd::serialize ( se
);
154 result
&= se
.write(CondSwapToBus32(m_address
), "Address" );
155 result
&= se
.write(CondSwapToBus32(m_nb_quadlets
), "Length (quadlets)" );
157 for (unsigned int i
=0; i
< m_nb_quadlets
; i
++) {
158 result
&= se
.write(CondSwapToBus32(m_data
[i
]), "Data");
164 EfcFlashWriteCmd::deserialize( Util::Cmd::IISDeserialize
& de
)
167 result
&= EfcCmd::deserialize ( de
);
172 EfcFlashWriteCmd::showEfcCmd()
174 EfcCmd::showEfcCmd();
175 debugOutput(DEBUG_LEVEL_NORMAL
, "EFC Flash Write:\n");
176 debugOutput(DEBUG_LEVEL_NORMAL
, " Address : %u\n", m_address
);
177 debugOutput(DEBUG_LEVEL_NORMAL
, " Length (quadlets) : %u\n", m_nb_quadlets
);
178 debugOutput(DEBUG_LEVEL_NORMAL
, " Data : \n");
179 for (unsigned int i
=0; i
< m_nb_quadlets
; i
++) {
180 debugOutput(DEBUG_LEVEL_NORMAL
, " %08X \n", m_data
[i
]);
184 // ------------------
186 EfcFlashLockCmd::EfcFlashLockCmd()
187 : EfcCmd(EFC_CAT_FLASH
, EFC_CMD_FLASH_LOCK
)
193 EfcFlashLockCmd::serialize( Util::Cmd::IOSSerialize
& se
)
197 // the length should be specified before
198 // the header is serialized
199 m_length
=EFC_HEADER_LENGTH_QUADLETS
+ 1;
201 result
&= EfcCmd::serialize ( se
);
202 result
&= se
.write(CondSwapToBus32(m_lock
), "Locked" );
208 EfcFlashLockCmd::deserialize( Util::Cmd::IISDeserialize
& de
)
212 result
&= EfcCmd::deserialize ( de
);
213 //EFC_DESERIALIZE_AND_SWAP(de, &m_lock, result);
218 EfcFlashLockCmd::showEfcCmd()
220 EfcCmd::showEfcCmd();
221 debugOutput(DEBUG_LEVEL_NORMAL
, "EFC Flash Lock:\n");
222 debugOutput(DEBUG_LEVEL_NORMAL
, " Locked : %s\n", (m_lock
?"Yes":"No"));
225 // ------------------
227 EfcFlashGetStatusCmd::EfcFlashGetStatusCmd()
228 : EfcCmd(EFC_CAT_FLASH
, EFC_CMD_FLASH_GET_STATUS
)
234 EfcFlashGetStatusCmd::serialize( Util::Cmd::IOSSerialize
& se
)
237 // the length should be specified before
238 // the header is serialized
239 m_length
=EFC_HEADER_LENGTH_QUADLETS
;
240 result
&= EfcCmd::serialize ( se
);
245 EfcFlashGetStatusCmd::deserialize( Util::Cmd::IISDeserialize
& de
)
248 result
&= EfcCmd::deserialize ( de
);
249 m_ready
= !(m_header
.retval
== eERV_FlashBusy
);
254 EfcFlashGetStatusCmd::showEfcCmd()
256 EfcCmd::showEfcCmd();
257 debugOutput(DEBUG_LEVEL_NORMAL
, "EFC Flash Get Status:\n");
258 debugOutput(DEBUG_LEVEL_NORMAL
, " Ready? : %s\n", (m_ready
?"Yes":"No"));
261 // ------------------
263 EfcFlashGetSessionBaseCmd::EfcFlashGetSessionBaseCmd()
264 : EfcCmd(EFC_CAT_FLASH
, EFC_CMD_FLASH_GET_SESSION_BASE
)
265 , m_address ( false )
270 EfcFlashGetSessionBaseCmd::serialize( Util::Cmd::IOSSerialize
& se
)
273 // the length should be specified before
274 // the header is serialized
275 m_length
=EFC_HEADER_LENGTH_QUADLETS
;
276 result
&= EfcCmd::serialize ( se
);
281 EfcFlashGetSessionBaseCmd::deserialize( Util::Cmd::IISDeserialize
& de
)
284 result
&= EfcCmd::deserialize ( de
);
285 EFC_DESERIALIZE_AND_SWAP(de
, &m_address
, result
);
290 EfcFlashGetSessionBaseCmd::showEfcCmd()
292 EfcCmd::showEfcCmd();
293 debugOutput(DEBUG_LEVEL_NORMAL
, "EFC Flash Get Session Base:\n");
294 debugOutput(DEBUG_LEVEL_NORMAL
, " Address : %u\n", m_address
);
297 } // namespace FireWorks