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/ac/linux/fd.h> 00020 00021 #include <libexplain/buffer/floppy_drive_params.h> 00022 #include <libexplain/buffer/int.h> 00023 #include <libexplain/buffer/long.h> 00024 #include <libexplain/buffer/pointer.h> 00025 #include <libexplain/is_efault.h> 00026 #include <libexplain/parse_bits.h> 00027 #include <libexplain/sizeof.h> 00028 00029 00030 #ifdef HAVE_LINUX_FD_H 00031 00032 static void 00033 explain_buffer_floppy_drive_params_flags(explain_string_buffer_t *sb, int value) 00034 { 00035 static const explain_parse_bits_table_t table[] = 00036 { 00037 { "FTD_MSG", FTD_MSG }, 00038 { "FD_BROKEN_DCL", FD_BROKEN_DCL }, 00039 { "FD_DEBUG", FD_DEBUG }, 00040 { "FD_SILENT_DCL_CLEAR", FD_SILENT_DCL_CLEAR }, 00041 { "FD_INVERTED_DCL", FD_INVERTED_DCL }, 00042 }; 00043 00044 explain_parse_bits_print(sb, value, table, SIZEOF(table)); 00045 } 00046 00047 00048 void 00049 explain_buffer_floppy_drive_params(explain_string_buffer_t *sb, 00050 const struct floppy_drive_params *data) 00051 { 00052 if (explain_is_efault_pointer(data, sizeof(*data))) 00053 { 00054 explain_buffer_pointer(sb, data); 00055 return; 00056 } 00057 00058 explain_string_buffer_puts(sb, "{ cmos = "); 00059 explain_buffer_int(sb, data->cmos); 00060 if (data->max_dtr) 00061 { 00062 explain_string_buffer_puts(sb, ", max_dtr = "); 00063 explain_buffer_ulong(sb, data->max_dtr); 00064 } 00065 if (data->hlt) 00066 { 00067 explain_string_buffer_puts(sb, ", hlt = "); 00068 explain_buffer_ulong(sb, data->hlt); 00069 } 00070 if (data->hut) 00071 { 00072 explain_string_buffer_puts(sb, ", hut = "); 00073 explain_buffer_ulong(sb, data->hut); 00074 } 00075 if (data->srt) 00076 { 00077 explain_string_buffer_puts(sb, ", srt = "); 00078 explain_buffer_ulong(sb, data->srt); 00079 } 00080 if (data->spinup) 00081 { 00082 explain_string_buffer_puts(sb, ", spinup = "); 00083 explain_buffer_ulong(sb, data->spinup); 00084 } 00085 if (data->spindown) 00086 { 00087 explain_string_buffer_puts(sb, ", spindown = "); 00088 explain_buffer_ulong(sb, data->spindown); 00089 } 00090 if (data->spindown_offset) 00091 { 00092 explain_string_buffer_puts(sb, ", spindown_offset = "); 00093 explain_buffer_ulong(sb, data->spindown_offset); 00094 } 00095 if (data->select_delay) 00096 { 00097 explain_string_buffer_puts(sb, ", select_delay = "); 00098 explain_buffer_int(sb, data->select_delay); 00099 } 00100 if (data->rps) 00101 { 00102 explain_string_buffer_puts(sb, ", rps = "); 00103 explain_buffer_int(sb, data->rps); 00104 } 00105 if (data->tracks) 00106 { 00107 explain_string_buffer_puts(sb, ", tracks = "); 00108 explain_buffer_int(sb, data->tracks); 00109 } 00110 if (data->timeout) 00111 { 00112 explain_string_buffer_puts(sb, ", timeout = "); 00113 explain_buffer_ulong(sb, data->timeout); 00114 } 00115 if (data->interleave_sect) 00116 { 00117 explain_string_buffer_puts(sb, ", interleave_sect = "); 00118 explain_buffer_int(sb, data->interleave_sect); 00119 } 00120 explain_string_buffer_puts(sb, ", flags = "); 00121 explain_buffer_floppy_drive_params_flags(sb, data->flags); 00122 if (data->read_track) 00123 { 00124 explain_string_buffer_puts(sb, ", read_track = "); 00125 explain_buffer_int(sb, data->read_track); 00126 } 00127 #if 0 00128 short autodetect[8]; 00129 #endif 00130 if (data->checkfreq) 00131 { 00132 explain_string_buffer_puts(sb, ", checkfreq = "); 00133 explain_buffer_int(sb, data->checkfreq); 00134 } 00135 if (data->native_format) 00136 { 00137 explain_string_buffer_puts(sb, ", native_format = "); 00138 explain_buffer_int(sb, data->native_format); 00139 } 00140 explain_string_buffer_puts(sb, " }"); 00141 } 00142 00143 #else 00144 00145 void 00146 explain_buffer_floppy_drive_params(explain_string_buffer_t *sb, 00147 const struct floppy_drive_params *data) 00148 { 00149 explain_buffer_pointer(sb, data); 00150 } 00151 00152 #endif 00153 00154 00155 /* vim: set ts=8 sw=4 et : */