libexplain
1.4.D001
|
00001 /* 00002 * libexplain - Explain errno values returned by libc functions 00003 * Copyright (C) 2009, 2011, 2013 Peter Miller 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU Lesser General Public License as 00007 * published by the Free Software Foundation; either version 3 of the 00008 * License, or (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public License 00016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00017 */ 00018 00019 #include <libexplain/buffer/char_data.h> 00020 #include <libexplain/buffer/ide_task_request_t.h> 00021 #include <libexplain/buffer/int.h> 00022 #include <libexplain/buffer/long.h> 00023 #include <libexplain/buffer/pointer.h> 00024 #include <libexplain/is_efault.h> 00025 #include <libexplain/parse_bits.h> 00026 #include <libexplain/sizeof.h> 00027 00028 00029 #ifdef HAVE_LINUX_HDREG_H 00030 00031 static void 00032 explain_buffer_ide_reg_valid_t(explain_string_buffer_t *sb, 00033 ide_reg_valid_t data) 00034 { 00035 int comma = 0; 00036 if (data.b.data) 00037 { 00038 explain_string_buffer_puts(sb, "data"); 00039 comma = 1; 00040 } 00041 if (data.b.error_feature) 00042 { 00043 if (comma) 00044 explain_string_buffer_puts(sb, ", "); 00045 explain_string_buffer_puts(sb, "error_feature"); 00046 comma = 1; 00047 } 00048 if (data.b.sector) 00049 { 00050 if (comma) 00051 explain_string_buffer_puts(sb, ", "); 00052 explain_string_buffer_puts(sb, "sector"); 00053 comma = 1; 00054 } 00055 if (data.b.nsector) 00056 { 00057 if (comma) 00058 explain_string_buffer_puts(sb, ", "); 00059 explain_string_buffer_puts(sb, "nsector"); 00060 comma = 1; 00061 } 00062 if (data.b.lcyl) 00063 { 00064 if (comma) 00065 explain_string_buffer_puts(sb, ", "); 00066 explain_string_buffer_puts(sb, "lcyl"); 00067 comma = 1; 00068 } 00069 if (data.b.hcyl) 00070 { 00071 if (comma) 00072 explain_string_buffer_puts(sb, ", "); 00073 explain_string_buffer_puts(sb, "hcyl"); 00074 comma = 1; 00075 } 00076 if (data.b.select) 00077 { 00078 if (comma) 00079 explain_string_buffer_puts(sb, ", "); 00080 explain_string_buffer_puts(sb, "select"); 00081 comma = 1; 00082 } 00083 if (data.b.status_command) 00084 { 00085 if (comma) 00086 explain_string_buffer_puts(sb, ", "); 00087 explain_string_buffer_puts(sb, "status_command"); 00088 comma = 1; 00089 } 00090 if (data.b.data_hob) 00091 { 00092 if (comma) 00093 explain_string_buffer_puts(sb, ", "); 00094 explain_string_buffer_puts(sb, "data_hob"); 00095 comma = 1; 00096 } 00097 if (data.b.error_feature_hob) 00098 { 00099 if (comma) 00100 explain_string_buffer_puts(sb, ", "); 00101 explain_string_buffer_puts(sb, "error_feature_hob"); 00102 comma = 1; 00103 } 00104 if (data.b.sector_hob) 00105 { 00106 if (comma) 00107 explain_string_buffer_puts(sb, ", "); 00108 explain_string_buffer_puts(sb, "sector_hob"); 00109 comma = 1; 00110 } 00111 if (data.b.nsector_hob) 00112 { 00113 if (comma) 00114 explain_string_buffer_puts(sb, ", "); 00115 explain_string_buffer_puts(sb, "nsector_hob"); 00116 comma = 1; 00117 } 00118 if (data.b.lcyl_hob) 00119 { 00120 if (comma) 00121 explain_string_buffer_puts(sb, ", "); 00122 explain_string_buffer_puts(sb, "lcyl_hob"); 00123 comma = 1; 00124 } 00125 if (data.b.hcyl_hob) 00126 { 00127 if (comma) 00128 explain_string_buffer_puts(sb, ", "); 00129 explain_string_buffer_puts(sb, "hcyl_hob"); 00130 comma = 1; 00131 } 00132 if (data.b.select_hob) 00133 { 00134 if (comma) 00135 explain_string_buffer_puts(sb, ", "); 00136 explain_string_buffer_puts(sb, "select_hob"); 00137 comma = 1; 00138 } 00139 if (data.b.control_hob) 00140 { 00141 if (comma) 00142 explain_string_buffer_puts(sb, ", "); 00143 explain_string_buffer_puts(sb, "control_hob"); 00144 comma = 1; 00145 } 00146 if (!comma) 00147 explain_string_buffer_puts(sb, "0"); 00148 } 00149 00150 00151 static void 00152 explain_buffer_req_cmd(explain_string_buffer_t *sb, int value) 00153 { 00154 static explain_parse_bits_table_t table[] = 00155 { 00156 #ifdef WIN_SRST 00157 { "WIN_SRST", WIN_SRST }, 00158 #endif 00159 #ifdef WIN_DEVICE_RESET 00160 { "WIN_DEVICE_RESET", WIN_DEVICE_RESET }, 00161 #endif 00162 #ifdef WIN_RECAL 00163 { "WIN_RECAL", WIN_RECAL }, 00164 #endif 00165 #ifdef WIN_RESTORE 00166 { "WIN_RESTORE", WIN_RESTORE }, 00167 #endif 00168 #ifdef WIN_READ 00169 { "WIN_READ", WIN_READ }, 00170 #endif 00171 #ifdef WIN_READ_ONCE 00172 { "WIN_READ_ONCE", WIN_READ_ONCE }, 00173 #endif 00174 #ifdef WIN_READ_LONG 00175 { "WIN_READ_LONG", WIN_READ_LONG }, 00176 #endif 00177 #ifdef WIN_READ_LONG_ONCE 00178 { "WIN_READ_LONG_ONCE", WIN_READ_LONG_ONCE }, 00179 #endif 00180 #ifdef WIN_READ_EXT 00181 { "WIN_READ_EXT", WIN_READ_EXT }, 00182 #endif 00183 #ifdef WIN_READDMA_EXT 00184 { "WIN_READDMA_EXT", WIN_READDMA_EXT }, 00185 #endif 00186 #ifdef WIN_READDMA_QUEUED_EXT 00187 { "WIN_READDMA_QUEUED_EXT", WIN_READDMA_QUEUED_EXT }, 00188 #endif 00189 #ifdef WIN_READ_NATIVE_MAX_EXT 00190 { "WIN_READ_NATIVE_MAX_EXT", WIN_READ_NATIVE_MAX_EXT }, 00191 #endif 00192 #ifdef WIN_MULTREAD_EXT 00193 { "WIN_MULTREAD_EXT", WIN_MULTREAD_EXT }, 00194 #endif 00195 #ifdef WIN_WRITE 00196 { "WIN_WRITE", WIN_WRITE }, 00197 #endif 00198 #ifdef WIN_WRITE_ONCE 00199 { "WIN_WRITE_ONCE", WIN_WRITE_ONCE }, 00200 #endif 00201 #ifdef WIN_WRITE_LONG 00202 { "WIN_WRITE_LONG", WIN_WRITE_LONG }, 00203 #endif 00204 #ifdef WIN_WRITE_LONG_ONCE 00205 { "WIN_WRITE_LONG_ONCE", WIN_WRITE_LONG_ONCE }, 00206 #endif 00207 #ifdef WIN_WRITE_EXT 00208 { "WIN_WRITE_EXT", WIN_WRITE_EXT }, 00209 #endif 00210 #ifdef WIN_WRITEDMA_EXT 00211 { "WIN_WRITEDMA_EXT", WIN_WRITEDMA_EXT }, 00212 #endif 00213 #ifdef WIN_WRITEDMA_QUEUED_EXT 00214 { "WIN_WRITEDMA_QUEUED_EXT", WIN_WRITEDMA_QUEUED_EXT }, 00215 #endif 00216 #ifdef WIN_SET_MAX_EXT 00217 { "WIN_SET_MAX_EXT", WIN_SET_MAX_EXT }, 00218 #endif 00219 #ifdef CFA_WRITE_SECT_WO_ERASE 00220 { "CFA_WRITE_SECT_WO_ERASE", CFA_WRITE_SECT_WO_ERASE }, 00221 #endif 00222 #ifdef WIN_MULTWRITE_EXT 00223 { "WIN_MULTWRITE_EXT", WIN_MULTWRITE_EXT }, 00224 #endif 00225 #ifdef WIN_WRITE_VERIFY 00226 { "WIN_WRITE_VERIFY", WIN_WRITE_VERIFY }, 00227 #endif 00228 #ifdef WIN_VERIFY 00229 { "WIN_VERIFY", WIN_VERIFY }, 00230 #endif 00231 #ifdef WIN_VERIFY_ONCE 00232 { "WIN_VERIFY_ONCE", WIN_VERIFY_ONCE }, 00233 #endif 00234 #ifdef WIN_VERIFY_EXT 00235 { "WIN_VERIFY_EXT", WIN_VERIFY_EXT }, 00236 #endif 00237 #ifdef WIN_FORMAT 00238 { "WIN_FORMAT", WIN_FORMAT }, 00239 #endif 00240 #ifdef WIN_INIT 00241 { "WIN_INIT", WIN_INIT }, 00242 #endif 00243 #ifdef WIN_SEEK 00244 { "WIN_SEEK", WIN_SEEK }, 00245 #endif 00246 #ifdef CFA_TRANSLATE_SECTOR 00247 { "CFA_TRANSLATE_SECTOR", CFA_TRANSLATE_SECTOR }, 00248 #endif 00249 #ifdef WIN_DIAGNOSE 00250 { "WIN_DIAGNOSE", WIN_DIAGNOSE }, 00251 #endif 00252 #ifdef WIN_SPECIFY 00253 { "WIN_SPECIFY", WIN_SPECIFY }, 00254 #endif 00255 #ifdef WIN_DOWNLOAD_MICROCODE 00256 { "WIN_DOWNLOAD_MICROCODE", WIN_DOWNLOAD_MICROCODE }, 00257 #endif 00258 #ifdef WIN_STANDBYNOW2 00259 { "WIN_STANDBYNOW2", WIN_STANDBYNOW2 }, 00260 #endif 00261 #ifdef WIN_STANDBY2 00262 { "WIN_STANDBY2", WIN_STANDBY2 }, 00263 #endif 00264 #ifdef WIN_SETIDLE2 00265 { "WIN_SETIDLE2", WIN_SETIDLE2 }, 00266 #endif 00267 #ifdef WIN_CHECKPOWERMODE2 00268 { "WIN_CHECKPOWERMODE2", WIN_CHECKPOWERMODE2 }, 00269 #endif 00270 #ifdef WIN_SLEEPNOW2 00271 { "WIN_SLEEPNOW2", WIN_SLEEPNOW2 }, 00272 #endif 00273 #ifdef WIN_PACKETCMD 00274 { "WIN_PACKETCMD", WIN_PACKETCMD }, 00275 #endif 00276 #ifdef WIN_PIDENTIFY 00277 { "WIN_PIDENTIFY", WIN_PIDENTIFY }, 00278 #endif 00279 #ifdef WIN_QUEUED_SERVICE 00280 { "WIN_QUEUED_SERVICE", WIN_QUEUED_SERVICE }, 00281 #endif 00282 #ifdef WIN_SMART 00283 { "WIN_SMART", WIN_SMART }, 00284 #endif 00285 #ifdef CFA_ERASE_SECTORS 00286 { "CFA_ERASE_SECTORS", CFA_ERASE_SECTORS }, 00287 #endif 00288 #ifdef WIN_MULTREAD 00289 { "WIN_MULTREAD", WIN_MULTREAD }, 00290 #endif 00291 #ifdef WIN_MULTWRITE 00292 { "WIN_MULTWRITE", WIN_MULTWRITE }, 00293 #endif 00294 #ifdef WIN_SETMULT 00295 { "WIN_SETMULT", WIN_SETMULT }, 00296 #endif 00297 #ifdef WIN_READDMA_QUEUED 00298 { "WIN_READDMA_QUEUED", WIN_READDMA_QUEUED }, 00299 #endif 00300 #ifdef WIN_READDMA 00301 { "WIN_READDMA", WIN_READDMA }, 00302 #endif 00303 #ifdef WIN_READDMA_ONCE 00304 { "WIN_READDMA_ONCE", WIN_READDMA_ONCE }, 00305 #endif 00306 #ifdef WIN_WRITEDMA 00307 { "WIN_WRITEDMA", WIN_WRITEDMA }, 00308 #endif 00309 #ifdef WIN_WRITEDMA_ONCE 00310 { "WIN_WRITEDMA_ONCE", WIN_WRITEDMA_ONCE }, 00311 #endif 00312 #ifdef WIN_WRITEDMA_QUEUED 00313 { "WIN_WRITEDMA_QUEUED", WIN_WRITEDMA_QUEUED }, 00314 #endif 00315 #ifdef CFA_WRITE_MULTI_WO_ERASE 00316 { "CFA_WRITE_MULTI_WO_ERASE", CFA_WRITE_MULTI_WO_ERASE }, 00317 #endif 00318 #ifdef WIN_GETMEDIASTATUS 00319 { "WIN_GETMEDIASTATUS", WIN_GETMEDIASTATUS }, 00320 #endif 00321 #ifdef WIN_ACKMEDIACHANGE 00322 { "WIN_ACKMEDIACHANGE", WIN_ACKMEDIACHANGE }, 00323 #endif 00324 #ifdef WIN_POSTBOOT 00325 { "WIN_POSTBOOT", WIN_POSTBOOT }, 00326 #endif 00327 #ifdef WIN_PREBOOT 00328 { "WIN_PREBOOT", WIN_PREBOOT }, 00329 #endif 00330 #ifdef WIN_DOORLOCK 00331 { "WIN_DOORLOCK", WIN_DOORLOCK }, 00332 #endif 00333 #ifdef WIN_DOORUNLOCK 00334 { "WIN_DOORUNLOCK", WIN_DOORUNLOCK }, 00335 #endif 00336 #ifdef WIN_STANDBYNOW1 00337 { "WIN_STANDBYNOW1", WIN_STANDBYNOW1 }, 00338 #endif 00339 #ifdef WIN_IDLEIMMEDIATE 00340 { "WIN_IDLEIMMEDIATE", WIN_IDLEIMMEDIATE }, 00341 #endif 00342 #ifdef WIN_STANDBY 00343 { "WIN_STANDBY", WIN_STANDBY }, 00344 #endif 00345 #ifdef WIN_SETIDLE1 00346 { "WIN_SETIDLE1", WIN_SETIDLE1 }, 00347 #endif 00348 #ifdef WIN_READ_BUFFER 00349 { "WIN_READ_BUFFER", WIN_READ_BUFFER }, 00350 #endif 00351 #ifdef WIN_CHECKPOWERMODE1 00352 { "WIN_CHECKPOWERMODE1", WIN_CHECKPOWERMODE1 }, 00353 #endif 00354 #ifdef WIN_SLEEPNOW1 00355 { "WIN_SLEEPNOW1", WIN_SLEEPNOW1 }, 00356 #endif 00357 #ifdef WIN_FLUSH_CACHE 00358 { "WIN_FLUSH_CACHE", WIN_FLUSH_CACHE }, 00359 #endif 00360 #ifdef WIN_WRITE_BUFFER 00361 { "WIN_WRITE_BUFFER", WIN_WRITE_BUFFER }, 00362 #endif 00363 #ifdef WIN_WRITE_SAME 00364 { "WIN_WRITE_SAME", WIN_WRITE_SAME }, 00365 #endif 00366 #ifdef WIN_FLUSH_CACHE_EXT 00367 { "WIN_FLUSH_CACHE_EXT", WIN_FLUSH_CACHE_EXT }, 00368 #endif 00369 #ifdef WIN_IDENTIFY 00370 { "WIN_IDENTIFY", WIN_IDENTIFY }, 00371 #endif 00372 #ifdef WIN_MEDIAEJECT 00373 { "WIN_MEDIAEJECT", WIN_MEDIAEJECT }, 00374 #endif 00375 #ifdef WIN_IDENTIFY_DMA 00376 { "WIN_IDENTIFY_DMA", WIN_IDENTIFY_DMA }, 00377 #endif 00378 #ifdef WIN_SETFEATURES 00379 { "WIN_SETFEATURES", WIN_SETFEATURES }, 00380 #endif 00381 #ifdef EXABYTE_ENABLE_NEST 00382 { "EXABYTE_ENABLE_NEST", EXABYTE_ENABLE_NEST }, 00383 #endif 00384 #ifdef WIN_SECURITY_SET_PASS 00385 { "WIN_SECURITY_SET_PASS", WIN_SECURITY_SET_PASS }, 00386 #endif 00387 #ifdef WIN_SECURITY_UNLOCK 00388 { "WIN_SECURITY_UNLOCK", WIN_SECURITY_UNLOCK }, 00389 #endif 00390 #ifdef WIN_SECURITY_ERASE_PREPARE 00391 { "WIN_SECURITY_ERASE_PREPARE", WIN_SECURITY_ERASE_PREPARE }, 00392 #endif 00393 #ifdef WIN_SECURITY_ERASE_UNIT 00394 { "WIN_SECURITY_ERASE_UNIT", WIN_SECURITY_ERASE_UNIT }, 00395 #endif 00396 #ifdef WIN_SECURITY_FREEZE_LOCK 00397 { "WIN_SECURITY_FREEZE_LOCK", WIN_SECURITY_FREEZE_LOCK }, 00398 #endif 00399 #ifdef WIN_SECURITY_DISABLE 00400 { "WIN_SECURITY_DISABLE", WIN_SECURITY_DISABLE }, 00401 #endif 00402 #ifdef WIN_READ_NATIVE_MAX 00403 { "WIN_READ_NATIVE_MAX", WIN_READ_NATIVE_MAX }, 00404 #endif 00405 #ifdef WIN_SET_MAX 00406 { "WIN_SET_MAX", WIN_SET_MAX }, 00407 #endif 00408 #ifdef DISABLE_SEAGATE 00409 { "DISABLE_SEAGATE", DISABLE_SEAGATE }, 00410 #endif 00411 }; 00412 00413 explain_parse_bits_print_single(sb, value, table, SIZEOF(table)); 00414 } 00415 00416 00417 void 00418 explain_buffer_ide_task_request_t(explain_string_buffer_t *sb, 00419 const ide_task_request_t *data) 00420 { 00421 if (explain_is_efault_pointer(data, sizeof(*data))) 00422 { 00423 explain_buffer_pointer(sb, data); 00424 return; 00425 } 00426 00427 explain_string_buffer_puts(sb, "{ io_ports = "); 00428 explain_buffer_char_data(sb, data->io_ports, sizeof(data->io_ports)); 00429 explain_string_buffer_puts(sb, ", hob_ports = "); 00430 explain_buffer_char_data(sb, data->hob_ports, sizeof(data->hob_ports)); 00431 explain_string_buffer_puts(sb, ", out_flags = "); 00432 explain_buffer_ide_reg_valid_t(sb, data->out_flags); 00433 explain_string_buffer_puts(sb, ", in_flags = "); 00434 explain_buffer_ide_reg_valid_t(sb, data->in_flags); 00435 explain_string_buffer_puts(sb, ", data_phase = "); 00436 explain_buffer_int(sb, data->data_phase); 00437 explain_string_buffer_puts(sb, ", req_cmd = "); 00438 explain_buffer_req_cmd(sb, data->req_cmd); 00439 explain_string_buffer_puts(sb, ", out_size = "); 00440 explain_buffer_ulong(sb, data->out_size); 00441 explain_string_buffer_puts(sb, ", in_size = "); 00442 explain_buffer_ulong(sb, data->in_size); 00443 explain_string_buffer_puts(sb, " }"); 00444 } 00445 00446 #else 00447 00448 void 00449 explain_buffer_ide_task_request_t(explain_string_buffer_t *sb, const void *data) 00450 { 00451 explain_buffer_pointer(sb, data); 00452 } 00453 00454 #endif 00455 00456 00457 /* vim: set ts=8 sw=4 et : */