printcis.c (0738c00eb5b47ee8ecc3cc256b7d54d9c375af6d) | printcis.c (c1d393d2076cb7b9e9d7dac0e5a93a0ff972dd54) |
---|---|
1/* 2 * Copyright (c) 1995 Andrew McRae. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 35 unchanged lines hidden (view full) --- 44#include <pccard/cardinfo.h> 45#include <pccard/cis.h> 46 47#include "readcis.h" 48 49static void dump_config_map(struct tuple *tp); 50static void dump_cis_config(struct tuple *tp); 51static void dump_other_cond(u_char *p, int len); | 1/* 2 * Copyright (c) 1995 Andrew McRae. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 35 unchanged lines hidden (view full) --- 44#include <pccard/cardinfo.h> 45#include <pccard/cis.h> 46 47#include "readcis.h" 48 49static void dump_config_map(struct tuple *tp); 50static void dump_cis_config(struct tuple *tp); 51static void dump_other_cond(u_char *p, int len); |
52static void dump_device_desc(u_char *p, int len, char *type); | 52static void dump_device_desc(u_char *p, int len, const char *type); |
53static void dump_info_v1(u_char *p, int len); 54static void dump_longlink_mfc(u_char *p, int len); 55static void dump_bar(u_char *p, int len); 56static void dump_device_geo(u_char *p, int len); 57static void dump_func_id(u_char *p); 58static void dump_serial_ext(u_char *p, int len); 59static void dump_disk_ext(u_char *p, int len); 60static void dump_network_ext(u_char *p, int len); --- 156 unchanged lines hidden (view full) --- 217 * Dump power descriptor. 218 * call from dump_cis_config() 219 */ 220static int 221print_pwr_desc(u_char *p) 222{ 223 int len = 1, i; 224 u_char mask; | 53static void dump_info_v1(u_char *p, int len); 54static void dump_longlink_mfc(u_char *p, int len); 55static void dump_bar(u_char *p, int len); 56static void dump_device_geo(u_char *p, int len); 57static void dump_func_id(u_char *p); 58static void dump_serial_ext(u_char *p, int len); 59static void dump_disk_ext(u_char *p, int len); 60static void dump_network_ext(u_char *p, int len); --- 156 unchanged lines hidden (view full) --- 217 * Dump power descriptor. 218 * call from dump_cis_config() 219 */ 220static int 221print_pwr_desc(u_char *p) 222{ 223 int len = 1, i; 224 u_char mask; |
225 char **expp; 226 static char *pname[] = | 225 const char **expp; 226 static const char *pname[] = |
227 {"Nominal operating supply voltage", 228 "Minimum operating supply voltage", 229 "Maximum operating supply voltage", 230 "Continuous supply current", 231 "Max current average over 1 second", 232 "Max current average over 10 ms", 233 "Power down supply current", 234 "Reserved" 235 }; | 227 {"Nominal operating supply voltage", 228 "Minimum operating supply voltage", 229 "Maximum operating supply voltage", 230 "Continuous supply current", 231 "Max current average over 1 second", 232 "Max current average over 10 ms", 233 "Power down supply current", 234 "Reserved" 235 }; |
236 static char *vexp[] = | 236 static const char *vexp[] = |
237 {"10uV", "100uV", "1mV", "10mV", "100mV", "1V", "10V", "100V"}; | 237 {"10uV", "100uV", "1mV", "10mV", "100mV", "1V", "10V", "100V"}; |
238 static char *cexp[] = | 238 static const char *cexp[] = |
239 {"10nA", "1uA", "10uA", "100uA", "1mA", "10mA", "100mA", "1A"}; | 239 {"10nA", "1uA", "10uA", "100uA", "1mA", "10mA", "100mA", "1A"}; |
240 static char *mant[] = | 240 static const char *mant[] = |
241 {"1", "1.2", "1.3", "1.5", "2", "2.5", "3", "3.5", "4", "4.5", 242 "5", "5.5", "6", "7", "8", "9"}; 243 244 mask = *p++; 245 expp = vexp; 246 for (i = 0; i < 8; i++) 247 if (mask & (1 << i)) { 248 len++; --- 16 unchanged lines hidden (view full) --- 265 266/* 267 * print_ext_speed - Print extended speed. 268 * call from dump_cis_config(), dump_device_desc() 269 */ 270static void 271print_ext_speed(u_char x, int scale) 272{ | 241 {"1", "1.2", "1.3", "1.5", "2", "2.5", "3", "3.5", "4", "4.5", 242 "5", "5.5", "6", "7", "8", "9"}; 243 244 mask = *p++; 245 expp = vexp; 246 for (i = 0; i < 8; i++) 247 if (mask & (1 << i)) { 248 len++; --- 16 unchanged lines hidden (view full) --- 265 266/* 267 * print_ext_speed - Print extended speed. 268 * call from dump_cis_config(), dump_device_desc() 269 */ 270static void 271print_ext_speed(u_char x, int scale) 272{ |
273 static char *mant[] = | 273 static const char *mant[] = |
274 {"Reserved", "1.0", "1.2", "1.3", "1.5", "2.0", "2.5", "3.0", 275 "3.5", "4.0", "4.5", "5.0", "5.5", "6.0", "7.0", "8.0"}; | 274 {"Reserved", "1.0", "1.2", "1.3", "1.5", "2.0", "2.5", "3.0", 275 "3.5", "4.0", "4.5", "5.0", "5.5", "6.0", "7.0", "8.0"}; |
276 static char *exp[] = | 276 static const char *exp[] = |
277 {"1 ns", "10 ns", "100 ns", "1 us", "10 us", "100 us", 278 "1 ms", "10 ms"}; | 277 {"1 ns", "10 ns", "100 ns", "1 us", "10 us", "100 us", 278 "1 ms", "10 ms"}; |
279 static char *scale_name[] = | 279 static const char *scale_name[] = |
280 {"None", "10", "100", "1,000", "10,000", "100,000", 281 "1,000,000", "10,000,000"}; 282 283 printf("Speed = %s x %s", mant[(x >> 3) & 0xF], exp[x & 7]); 284 if (scale) 285 printf(", scaled by %s", scale_name[scale & 7]); 286} 287 288/* 289 * Print variable length value. 290 * call from print_io_map(), print_mem_map() 291 */ 292static int | 280 {"None", "10", "100", "1,000", "10,000", "100,000", 281 "1,000,000", "10,000,000"}; 282 283 printf("Speed = %s x %s", mant[(x >> 3) & 0xF], exp[x & 7]); 284 if (scale) 285 printf(", scaled by %s", scale_name[scale & 7]); 286} 287 288/* 289 * Print variable length value. 290 * call from print_io_map(), print_mem_map() 291 */ 292static int |
293print_num(int sz, char *fmt, u_char *p, int ofs) | 293print_num(int sz, const char *fmt, u_char *p, int ofs) |
294{ 295 switch (sz) { 296 case 0: 297 case 0x10: 298 return 0; 299 case 1: 300 case 0x11: 301 printf(fmt, *p + ofs); --- 388 unchanged lines hidden (view full) --- 690 } 691} 692 693/* 694 * CIS_MEM_COMMON, CIS_MEM_ATTR: 695 * Common / Attribute memory descripter 696 */ 697static void | 294{ 295 switch (sz) { 296 case 0: 297 case 0x10: 298 return 0; 299 case 1: 300 case 0x11: 301 printf(fmt, *p + ofs); --- 388 unchanged lines hidden (view full) --- 690 } 691} 692 693/* 694 * CIS_MEM_COMMON, CIS_MEM_ATTR: 695 * Common / Attribute memory descripter 696 */ 697static void |
698dump_device_desc(u_char *p, int len, char *type) | 698dump_device_desc(u_char *p, int len, const char *type) |
699{ | 699{ |
700 static char *un_name[] = | 700 static const char *un_name[] = |
701 {"512b", "2Kb", "8Kb", "32Kb", "128Kb", "512Kb", "2Mb", "reserved"}; | 701 {"512b", "2Kb", "8Kb", "32Kb", "128Kb", "512Kb", "2Mb", "reserved"}; |
702 static char *speed[] = | 702 static const char *speed[] = |
703 {"No speed", "250nS", "200nS", "150nS", 704 "100nS", "Reserved", "Reserved"}; | 703 {"No speed", "250nS", "200nS", "150nS", 704 "100nS", "Reserved", "Reserved"}; |
705 static char *dev[] = | 705 static const char *dev[] = |
706 {"No device", "Mask ROM", "OTPROM", "UV EPROM", 707 "EEPROM", "FLASH EEPROM", "SRAM", "DRAM", 708 "Reserved", "Reserved", "Reserved", "Reserved", 709 "Reserved", "Function specific", "Extended", 710 "Reserved"}; 711 int count = 0; 712 713 while (*p != 0xFF && len > 0) { --- 59 unchanged lines hidden (view full) --- 773} 774 775/* 776 * CIS_FUNC_ID: Functional ID 777 */ 778static void 779dump_func_id(u_char *p) 780{ | 706 {"No device", "Mask ROM", "OTPROM", "UV EPROM", 707 "EEPROM", "FLASH EEPROM", "SRAM", "DRAM", 708 "Reserved", "Reserved", "Reserved", "Reserved", 709 "Reserved", "Function specific", "Extended", 710 "Reserved"}; 711 int count = 0; 712 713 while (*p != 0xFF && len > 0) { --- 59 unchanged lines hidden (view full) --- 773} 774 775/* 776 * CIS_FUNC_ID: Functional ID 777 */ 778static void 779dump_func_id(u_char *p) 780{ |
781 static char *id[] = { | 781 static const char *id[] = { |
782 "Multifunction card", 783 "Memory card", 784 "Serial port/modem", 785 "Parallel port", 786 "Fixed disk card", 787 "Video adapter", 788 "Network/LAN adapter", 789 "AIMS", --- 9 unchanged lines hidden (view full) --- 799 800/* 801 * CIS_FUNC_EXT: Dump functional extension tuple. 802 * (Serial port/modem) 803 */ 804static void 805dump_serial_ext(u_char *p, int len) 806{ | 782 "Multifunction card", 783 "Memory card", 784 "Serial port/modem", 785 "Parallel port", 786 "Fixed disk card", 787 "Video adapter", 788 "Network/LAN adapter", 789 "AIMS", --- 9 unchanged lines hidden (view full) --- 799 800/* 801 * CIS_FUNC_EXT: Dump functional extension tuple. 802 * (Serial port/modem) 803 */ 804static void 805dump_serial_ext(u_char *p, int len) 806{ |
807 static char *type[] = { | 807 static const char *type[] = { |
808 "", "Modem", "Data", "Fax", "Voice", "Data modem", 809 "Fax/modem", "Voice", " (Data)", " (Fax)", " (Voice)" 810 }; 811 812 if (len < 1) 813 return; 814 switch (p[0]) { 815 case 0: /* Serial */ 816 case 8: /* Data */ 817 case 9: /* Fax */ 818 case 10: /* Voice */ 819 printf("\tSerial interface extension:%s\n", type[*p]); 820 if (len < 4) 821 goto err; 822 switch (p[1] & 0x1F) { 823 default: | 808 "", "Modem", "Data", "Fax", "Voice", "Data modem", 809 "Fax/modem", "Voice", " (Data)", " (Fax)", " (Voice)" 810 }; 811 812 if (len < 1) 813 return; 814 switch (p[0]) { 815 case 0: /* Serial */ 816 case 8: /* Data */ 817 case 9: /* Fax */ 818 case 10: /* Voice */ 819 printf("\tSerial interface extension:%s\n", type[*p]); 820 if (len < 4) 821 goto err; 822 switch (p[1] & 0x1F) { 823 default: |
824 printf("\t\tUnkn device"); | 824 printf("\t\tUnknown device"); |
825 break; 826 case 0: 827 printf("\t\t8250 UART"); 828 break; 829 case 1: 830 printf("\t\t16450 UART"); 831 break; 832 case 2: --- 275 unchanged lines hidden --- | 825 break; 826 case 0: 827 printf("\t\t8250 UART"); 828 break; 829 case 1: 830 printf("\t\t16450 UART"); 831 break; 832 case 2: --- 275 unchanged lines hidden --- |