Main Page | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

detect.c

Go to the documentation of this file.
00001 /*
00002  *      This program is free software; you can redistribute it and/or
00003  *      modify it under the terms of the GNU General Public License
00004  *      as published by the Free Software Foundation; either version
00005  *      2 of the License, or (at your option) any later version.
00006  *
00007  *  Copyright 1999-2005 Michael Klein <michael(dot)klein(at)puffin(dot)lb(dot)shuttle(dot)de>
00008  *  Copyright 2001-2005 Spiro Trikaliotis
00009  *
00010 */
00011 
00022 #define DBG_USERMODE
00023 
00025 #define DBG_PROGNAME "OPENCBM.DLL"
00026 
00027 #include "debug.h"
00028 
00029 #include <stdlib.h>
00030 
00032 #define DLL
00033 #include "opencbm.h"
00034 #include "archlib.h"
00035 
00036 
00064 int CBMAPIDECL 
00065 cbm_identify(CBM_FILE HandleDevice, __u_char DeviceAddress,
00066              enum cbm_device_type_e *CbmDeviceType, 
00067              const char **CbmDeviceString)
00068 {
00069     enum cbm_device_type_e deviceType = cbm_dt_unknown;
00070     unsigned short magic;
00071     unsigned char buf[3];
00072     const char command[] = { 'M', '-', 'R', (char) 0x40, (char) 0xff, (char) 0x02 };
00073     char *deviceString = "*unknown*";
00074     int rv = -1;
00075 
00076     FUNC_ENTER();
00077 
00078     if (cbm_exec_command(HandleDevice, DeviceAddress, command, sizeof(command)) == 0 
00079         && cbmarch_talk(HandleDevice, DeviceAddress, 15) == 0)
00080     {
00081         if (cbmarch_raw_read(HandleDevice, buf, 3) == 3)
00082         {
00083             magic = buf[0] | (buf[1] << 8);
00084 
00085             switch(magic)
00086             {
00087                 case 0xaaaa:
00088                     deviceType = cbm_dt_cbm1541;
00089                     deviceString = "1540 or 1541"; 
00090                     break;
00091 
00092                 case 0xf00f:
00093                     deviceType = cbm_dt_cbm1541;
00094                     deviceString = "1541-II";
00095                     break;
00096 
00097                 case 0xcd18:
00098                     deviceType = cbm_dt_cbm1541;
00099                     deviceString = "1541C";
00100                     break;
00101 
00102                 case 0x10ca:
00103                     deviceType = cbm_dt_cbm1541;
00104                     deviceString = "DolphinDOS 1541";
00105                     break;
00106 
00107                 case 0x6f10:
00108                     deviceType = cbm_dt_cbm1541;
00109                     deviceString = "SpeedDOS 1541";
00110                     break;
00111 
00112                 case 0x8085:
00113                     deviceType = cbm_dt_cbm1541;
00114                     deviceString = "JiffyDOS 1541";
00115                     break;
00116 
00117                 case 0xaeea:
00118                     deviceType = cbm_dt_cbm1541;
00119                     deviceString = "64'er DOS 1541";
00120                     break;
00121 
00122                 case 0xfed7:
00123                     deviceType = cbm_dt_cbm1570;
00124                     deviceString = "1570";
00125                     break;
00126 
00127                 case 0x02ac:
00128                     deviceType = cbm_dt_cbm1571;
00129                     deviceString = "1571";
00130                     break;
00131 
00132                 case 0x01ba:
00133                     deviceType = cbm_dt_cbm1581;
00134                     deviceString = "1581";
00135                     break;
00136             }
00137             rv = 0;
00138         }
00139         cbmarch_untalk(HandleDevice);
00140     }
00141 
00142     if(CbmDeviceType)
00143     {
00144         *CbmDeviceType = deviceType;
00145     }
00146 
00147     if(CbmDeviceString) 
00148     {
00149         *CbmDeviceString = deviceString;
00150     }
00151 
00152     FUNC_LEAVE_INT(rv);
00153 }

Generated on Sun Apr 30 18:45:48 2006 for opencbm by  doxygen 1.4.2