|
Packit |
dd8086 |
/*
|
|
Packit |
dd8086 |
Copyright (C) 2010, 2012, 2017 Rocky Bernstein <rocky@gnu.org>
|
|
Packit |
dd8086 |
|
|
Packit |
dd8086 |
This program is free software: you can redistribute it and/or modify
|
|
Packit |
dd8086 |
it under the terms of the GNU General Public License as published by
|
|
Packit |
dd8086 |
the Free Software Foundation, either version 3 of the License, or
|
|
Packit |
dd8086 |
(at your option) any later version.
|
|
Packit |
dd8086 |
|
|
Packit |
dd8086 |
This program is distributed in the hope that it will be useful,
|
|
Packit |
dd8086 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
dd8086 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
dd8086 |
GNU General Public License for more details.
|
|
Packit |
dd8086 |
|
|
Packit |
dd8086 |
You should have received a copy of the GNU General Public License
|
|
Packit |
dd8086 |
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
Packit |
dd8086 |
*/
|
|
Packit |
dd8086 |
|
|
Packit |
dd8086 |
#ifndef CDIO_DRIVER_MMC_CMD_HELPER_H_
|
|
Packit |
dd8086 |
#define CDIO_DRIVER_MMC_CMD_HELPER_H_
|
|
Packit |
dd8086 |
|
|
Packit |
dd8086 |
/* Boilerplate initialization code to setup running MMC command. We
|
|
Packit |
dd8086 |
assume variables 'p_cdio', 'p_buf', and 'i_size' are previously
|
|
Packit |
dd8086 |
defined. It does the following:
|
|
Packit |
dd8086 |
|
|
Packit |
dd8086 |
1. Defines a cdb variable,
|
|
Packit |
dd8086 |
2. zeros cdb variable
|
|
Packit |
dd8086 |
3 Checks to see if we have a cdio object and can run an MMC command
|
|
Packit |
dd8086 |
4. Sets up the command field of cdb to passed in value mmc_cmd.
|
|
Packit |
dd8086 |
*/
|
|
Packit |
dd8086 |
#define MMC_CMD_SETUP(mmc_cmd) \
|
|
Packit |
dd8086 |
mmc_cdb_t cdb = {{0, }}; \
|
|
Packit |
dd8086 |
\
|
|
Packit |
dd8086 |
if ( ! p_cdio ) return DRIVER_OP_UNINIT; \
|
|
Packit |
dd8086 |
if ( ! p_cdio->op.run_mmc_cmd ) return DRIVER_OP_UNSUPPORTED; \
|
|
Packit |
dd8086 |
\
|
|
Packit |
dd8086 |
CDIO_MMC_SET_COMMAND(cdb.field, mmc_cmd)
|
|
Packit |
dd8086 |
|
|
Packit |
dd8086 |
/* Boilerplate initialization code to setup running MMC read command
|
|
Packit |
dd8086 |
needs to set the cdb 16-bit length field. See above
|
|
Packit |
dd8086 |
comment for MMC_CMD_SETUP.
|
|
Packit |
dd8086 |
*/
|
|
Packit |
dd8086 |
#define MMC_CMD_SETUP_READ16(mmc_cmd) \
|
|
Packit |
dd8086 |
MMC_CMD_SETUP(mmc_cmd); \
|
|
Packit |
dd8086 |
\
|
|
Packit |
dd8086 |
/* Setup to read header, to get length of data */ \
|
|
Packit |
dd8086 |
CDIO_MMC_SET_READ_LENGTH16(cdb.field, i_size)
|
|
Packit |
dd8086 |
|
|
Packit |
dd8086 |
/* Boilerplate code to run a MMC command.
|
|
Packit |
dd8086 |
|
|
Packit |
dd8086 |
We assume variables 'p_cdio', 'mmc_timeout_ms', 'cdb', 'i_size' and
|
|
Packit |
dd8086 |
'p_buf' are defined previously.
|
|
Packit |
dd8086 |
|
|
Packit |
dd8086 |
'direction' is the SCSI direction (read, write, none) of the
|
|
Packit |
dd8086 |
command.
|
|
Packit |
dd8086 |
*/
|
|
Packit |
dd8086 |
#define MMC_RUN_CMD(direction, i_timeout) \
|
|
Packit |
dd8086 |
p_cdio->op.run_mmc_cmd(p_cdio->env, \
|
|
Packit |
dd8086 |
i_timeout, \
|
|
Packit |
dd8086 |
mmc_get_cmd_len(cdb.field[0]), \
|
|
Packit |
dd8086 |
&cdb, \
|
|
Packit |
dd8086 |
direction, i_size, p_buf)
|
|
Packit |
dd8086 |
|
|
Packit |
dd8086 |
#endif /* CDIO_DRIVER_MMC_CMD_HELPER_H_ */
|