]> FriiDump Source - friidump.git/blob - libfriidump/dvd_drive.h
Fix MSVC CMake SHA1 header resolution
[friidump.git] / libfriidump / dvd_drive.h
1 /***************************************************************************
2  *   Copyright (C) 2007 by Arep                                            *
3  *   Support is provided through the forums at                             *
4  *   http://wii.console-tribe.com                                          *
5  *                                                                         *
6  *   This program is free software; you can redistribute it and/or modify  *
7  *   it under the terms of the GNU General Public License as published by  *
8  *   the Free Software Foundation; either version 2 of the License, or     *
9  *   (at your option) any later version.                                   *
10  *                                                                         *
11  *   This program is distributed in the hope that it will be useful,       *
12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
14  *   GNU General Public License for more details.                          *
15  *                                                                         *
16  *   You should have received a copy of the GNU General Public License     *
17  *   along with this program; if not, write to the                         *
18  *   Free Software Foundation, Inc.,                                       *
19  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
20  ***************************************************************************/
21
22 #ifndef DVD_DRIVE_H_INCLUDED
23 #define DVD_DRIVE_H_INCLUDED
24
25 #include "misc.h"
26 #include <sys/types.h>
27
28
29 typedef struct dvd_drive_s dvd_drive;
30
31
32 typedef enum {
33         DVD_VOLUME_LOCK_OK = 0,
34         DVD_VOLUME_LOCK_UNAVAILABLE = 1,
35         DVD_VOLUME_LOCK_FAILED = -1
36 } dvd_volume_lock_result;
37
38 typedef struct {
39         int sense_key;
40         int asc;
41         int ascq;
42 } req_sense;
43
44 /* Snapshot of the most recently executed MMC command.  This is retained even
45  * when the caller requested quiet error handling so release builds can report
46  * actionable seed/cache transport diagnostics without enabling DEBUG/VERBOSE. */
47 typedef struct {
48         bool valid;
49         int transport_result;
50         int os_error;
51         int scsi_status;
52         int sense_key;
53         int asc;
54         int ascq;
55         int cdb_length;
56         u_int8_t cdb[12];
57 } dvd_command_diagnostic;
58
59 /* Read-only metadata for an exact HLDS/MN103 0xE7 profile match.
60  * Static firmware addresses are diagnostic evidence only. FriiDump does not
61  * execute these addresses or issue firmware-write commands through this API. */
62 typedef struct {
63         u_int32_t type;
64         u_int32_t cache_base;
65         u_int32_t mem_blocks;
66         int preferred_method;
67         const char *label;
68         const char *support_tier;
69         const char *family;
70         const char *tokens;
71         const char *record_id;
72         u_int32_t static_cdb_base;
73         u_int32_t static_gate;
74         const char *notes;
75 } dvd_hlds_e7_profile_info;
76
77
78 typedef enum {
79         DVD_DATA_NONE = 0,
80         DVD_DATA_IN = 1,
81         DVD_DATA_OUT = 2
82 } dvd_data_direction;
83
84 typedef struct {
85         u_int8_t cmd[12];
86         int cmdlen;
87         dvd_data_direction direction;
88         req_sense *sense;
89         u_int8_t *buffer;
90         int buflen;
91 } mmc_command;
92
93
94 /* Functions */
95 dvd_drive *dvd_drive_new (char *device, u_int32_t command);
96 void *dvd_drive_destroy (dvd_drive *d);
97 int dvd_read_sector_dummy (dvd_drive *dvd, u_int32_t sector, u_int32_t sectors, req_sense *sense, u_int8_t *extbuf, size_t extbufsize);
98 int dvd_read_sector_streaming (dvd_drive *dvd, u_int32_t sector, req_sense *sense, u_int8_t *extbuf, size_t extbufsize);
99 int dvd_read_streaming (dvd_drive *dvd, u_int32_t sector, u_int32_t sectors, req_sense *sense, u_int8_t *extbuf, size_t extbufsize);
100 int dvd_flush_cache_READ12 (dvd_drive *dvd, u_int32_t sector, req_sense *sense);
101 int dvd_start_stop_unit (dvd_drive *dvd, bool start, bool load_eject, req_sense *sense);
102 int dvd_set_door_lock (dvd_drive *dvd, bool locked);
103 int dvd_stop_unit (dvd_drive *dvd, bool start, req_sense *sense);
104 int dvd_media_cycle (dvd_drive *dvd, req_sense *sense);
105 int dvd_wait_ready (dvd_drive *dvd, unsigned int timeout_ms);
106 int dvd_test_unit_ready (dvd_drive *dvd, req_sense *sense);
107 int dvd_read_capacity_10 (dvd_drive *dvd, u_int32_t *sectors, u_int32_t *sector_size, req_sense *sense);
108 int dvd_read_10 (dvd_drive *dvd, u_int32_t sector, u_int32_t sectors, req_sense *sense, u_int8_t *extbuf, size_t extbufsize);
109 int dvd_mode_sense_10 (dvd_drive *dvd, u_int8_t page, u_int8_t *extbuf, size_t extbufsize, req_sense *sense);
110 int dvd_mode_select_10 (dvd_drive *dvd, const u_int8_t *buf, size_t bufsize, req_sense *sense);
111 int dvd_mode_select_6 (dvd_drive *dvd, const u_int8_t *buf, size_t bufsize, req_sense *sense);
112 int dvd_read_dvd_structure (dvd_drive *dvd, u_int8_t format, u_int8_t layer, u_int8_t *extbuf, size_t extbufsize, req_sense *sense);
113 int dvd_xbox_gdr8050l_unlock (dvd_drive *dvd, u_int32_t *unlocked_sectors);
114 int dvd_xbox_vendor_lock (dvd_drive *dvd);
115 int dvd_xbox_vendor_unlock_wxripper (dvd_drive *dvd, u_int32_t *unlocked_sectors);
116 int dvd_xbox_vendor_set_error_skip (dvd_drive *dvd, bool enabled);
117 int dvd_xbox_prepare_game_view (dvd_drive *dvd, u_int32_t *sectors, u_int32_t *sector_size);
118 int dvd_refresh_volume (dvd_drive *dvd);
119 int dvd_lock_volume (dvd_drive *dvd);
120 int dvd_xbox_refresh_volume (dvd_drive *dvd);
121 int dvd_xbox_lock_volume (dvd_drive *dvd);
122 bool dvd_is_xbox_drive (dvd_drive *dvd);
123 bool dvd_is_xbox_unlock_drive (dvd_drive *dvd);
124 bool dvd_is_xbox_challenge_drive (dvd_drive *dvd);
125 bool dvd_is_xbox_vendor_unlock_drive (dvd_drive *dvd);
126 int dvd_set_speed (dvd_drive *dvd, u_int32_t speed, req_sense *sense);
127 int dvd_get_size (dvd_drive *dvd, u_int32_t *size, req_sense *sense);
128 int dvd_get_layerbreak (dvd_drive *dvd, u_int32_t *layerbreak, req_sense *sense);
129 int dvd_set_streaming (dvd_drive *dvd, u_int32_t speed, req_sense *sense);
130 int dvd_memdump (dvd_drive *dvd, u_int32_t block_off, u_int32_t block_len, u_int32_t block_size, u_int8_t *buf);
131 char *dvd_get_vendor (dvd_drive *dvd);
132 char *dvd_get_product_id (dvd_drive *dvd);
133 char *dvd_get_product_revision (dvd_drive *dvd);
134 char *dvd_get_model_string (dvd_drive *dvd);
135 char *dvd_get_device (dvd_drive *dvd);
136 void *dvd_get_native_handle (dvd_drive *dvd);
137 bool dvd_get_support_status (dvd_drive *dvd);
138 u_int32_t dvd_get_def_method (dvd_drive *dvd);
139 u_int32_t dvd_get_command (dvd_drive *dvd);
140 bool dvd_lookup_hlds_e7_profile (
141         const char *vendor,
142         const char *product_id,
143         const char *revision,
144         dvd_hlds_e7_profile_info *out
145 );
146 u_int32_t dvd_detect_hlds_e7_type_for_identity (
147         const char *vendor,
148         const char *product_id,
149         const char *revision
150 );
151 const char *dvd_get_hlds_e7_profile_name (dvd_drive *dvd);
152 const char *dvd_get_hlds_e7_support_tier (dvd_drive *dvd);
153 const char *dvd_get_hlds_e7_family (dvd_drive *dvd);
154 const char *dvd_get_hlds_e7_tokens (dvd_drive *dvd);
155 const char *dvd_get_hlds_e7_record_id (dvd_drive *dvd);
156 const char *dvd_get_hlds_e7_notes (dvd_drive *dvd);
157 u_int32_t dvd_get_hlds_e7_type (dvd_drive *dvd);
158 u_int32_t dvd_get_hlds_e7_cache_base (dvd_drive *dvd);
159 u_int32_t dvd_get_hlds_e7_mem_blocks (dvd_drive *dvd);
160 u_int32_t dvd_get_hlds_e7_static_cdb_base (dvd_drive *dvd);
161 u_int32_t dvd_get_hlds_e7_static_gate (dvd_drive *dvd);
162 int dvd_get_hlds_e7_preferred_method (dvd_drive *dvd);
163 void dvd_set_hlds_e7_runtime_profile (dvd_drive *dvd, u_int32_t type, u_int32_t cache_base, u_int32_t mem_blocks);
164
165 /* The following are exported for use by drive-specific functions */
166 typedef int (*dvd_drive_memdump_func) (dvd_drive *dvd, u_int32_t block_off, u_int32_t block_len, u_int32_t block_size, u_int8_t *buf);
167 void dvd_init_command (mmc_command *mmc, u_int8_t *buf, int len, req_sense *sense);
168 int dvd_execute_cmd (dvd_drive *dvd, mmc_command *mmc, bool ignore_errors);
169 bool dvd_get_last_command_diagnostic (dvd_drive *dvd, dvd_command_diagnostic *out);
170
171 #endif