00001
00002
00003
00004
00005
00006
00007
00008
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 #include <string.h>
00031
00033 #define DLL
00034 #include "opencbm.h"
00035 #include "archlib.h"
00036
00037
00038
00039
00040
00041
00042
00043
00060 const char * CBMAPIDECL
00061 cbm_get_driver_name(int PortNumber)
00062 {
00063 FUNC_ENTER();
00064
00065 FUNC_LEAVE_STRING(cbmarch_get_driver_name(PortNumber));
00066 }
00067
00088 int CBMAPIDECL
00089 cbm_driver_open(CBM_FILE *HandleDevice, int PortNumber)
00090 {
00091 FUNC_ENTER();
00092
00093 FUNC_LEAVE_INT(cbmarch_driver_open(HandleDevice, PortNumber));
00094 }
00095
00110 void CBMAPIDECL
00111 cbm_driver_close(CBM_FILE HandleDevice)
00112 {
00113 FUNC_ENTER();
00114
00115 cbmarch_driver_close(HandleDevice);
00116
00117 FUNC_LEAVE();
00118 }
00119
00144 void CBMAPIDECL
00145 cbm_lock(CBM_FILE HandleDevice)
00146 {
00147 FUNC_ENTER();
00148
00149 cbmarch_lock(HandleDevice);
00150
00151 FUNC_LEAVE();
00152 }
00153
00171 void CBMAPIDECL
00172 cbm_unlock(CBM_FILE HandleDevice)
00173 {
00174 FUNC_ENTER();
00175
00176 cbmarch_unlock(HandleDevice);
00177
00178 FUNC_LEAVE();
00179 }
00180
00181
00182
00183
00208 int CBMAPIDECL
00209 cbm_raw_write(CBM_FILE HandleDevice, const void *Buffer, size_t Count)
00210 {
00211 FUNC_ENTER();
00212
00213 #ifdef DBG_DUMP_RAW_WRITE
00214 DBG_MEMDUMP("cbm_raw_write", Buffer, Count);
00215 #endif
00216
00217 FUNC_LEAVE_INT(cbmarch_raw_write(HandleDevice,Buffer, Count));
00218 }
00219
00220
00244 int CBMAPIDECL
00245 cbm_raw_read(CBM_FILE HandleDevice, void *Buffer, size_t Count)
00246 {
00247 int bytesRead;
00248
00249 FUNC_ENTER();
00250
00251 bytesRead = cbmarch_raw_read(HandleDevice, Buffer, Count);
00252
00253 #ifdef DBG_DUMP_RAW_READ
00254 DBG_MEMDUMP("cbm_raw_read", Buffer, bytesRead);
00255 #endif
00256
00257 FUNC_LEAVE_INT(bytesRead);
00258 }
00259
00283 int CBMAPIDECL
00284 cbm_listen(CBM_FILE HandleDevice, __u_char DeviceAddress, __u_char SecondaryAddress)
00285 {
00286 FUNC_ENTER();
00287
00288 FUNC_LEAVE_INT(cbmarch_listen(HandleDevice, DeviceAddress, SecondaryAddress));
00289 }
00290
00314 int CBMAPIDECL
00315 cbm_talk(CBM_FILE HandleDevice, __u_char DeviceAddress, __u_char SecondaryAddress)
00316 {
00317 FUNC_ENTER();
00318
00319 FUNC_LEAVE_INT(cbmarch_talk(HandleDevice, DeviceAddress, SecondaryAddress));
00320 }
00321
00350 int CBMAPIDECL
00351 cbm_open(CBM_FILE HandleDevice, __u_char DeviceAddress, __u_char SecondaryAddress,
00352 const void *Filename, size_t FilenameLength)
00353 {
00354 int returnValue;
00355
00356 FUNC_ENTER();
00357
00358 if (cbmarch_open(HandleDevice, DeviceAddress, SecondaryAddress) == 0)
00359 {
00360 returnValue = 0;
00361
00362 if(Filename != NULL)
00363 {
00364 if (FilenameLength == 0)
00365 {
00366 DBG_WARN((DBG_PREFIX "*** FilenameLength of 0 encountered!"));
00367 FilenameLength = strlen(Filename);
00368 }
00369
00370 if (FilenameLength > 0)
00371 {
00372 returnValue =
00373 (size_t) (cbm_raw_write(HandleDevice, Filename, FilenameLength))
00374 != FilenameLength;
00375 }
00376 cbm_unlisten(HandleDevice);
00377 }
00378 }
00379 else
00380 {
00381 returnValue = -1;
00382 }
00383
00384 FUNC_LEAVE_INT(returnValue);
00385 }
00386
00408 int CBMAPIDECL
00409 cbm_close(CBM_FILE HandleDevice, __u_char DeviceAddress, __u_char SecondaryAddress)
00410 {
00411 FUNC_ENTER();
00412
00413 FUNC_LEAVE_INT(cbmarch_close(HandleDevice, DeviceAddress, SecondaryAddress));
00414 }
00415
00436 int CBMAPIDECL
00437 cbm_unlisten(CBM_FILE HandleDevice)
00438 {
00439 FUNC_ENTER();
00440
00441 FUNC_LEAVE_INT(cbmarch_unlisten(HandleDevice));
00442 }
00443
00464 int CBMAPIDECL
00465 cbm_untalk(CBM_FILE HandleDevice)
00466 {
00467 FUNC_ENTER();
00468
00469 FUNC_LEAVE_INT(cbmarch_untalk(HandleDevice));
00470 }
00471
00472
00493 int CBMAPIDECL
00494 cbm_get_eoi(CBM_FILE HandleDevice)
00495 {
00496 FUNC_ENTER();
00497
00498 FUNC_LEAVE_INT(cbmarch_get_eoi(HandleDevice));
00499 }
00500
00516 int CBMAPIDECL
00517 cbm_clear_eoi(CBM_FILE HandleDevice)
00518 {
00519 FUNC_ENTER();
00520
00521 FUNC_LEAVE_INT(cbmarch_clear_eoi(HandleDevice));
00522 }
00523
00545 int CBMAPIDECL
00546 cbm_reset(CBM_FILE HandleDevice)
00547 {
00548 FUNC_ENTER();
00549
00550 FUNC_LEAVE_INT(cbmarch_reset(HandleDevice));
00551 }
00552
00553
00554
00555
00556
00578 __u_char CBMAPIDECL
00579 cbm_pp_read(CBM_FILE HandleDevice)
00580 {
00581 FUNC_ENTER();
00582
00583 FUNC_LEAVE_UCHAR(cbmarch_pp_read(HandleDevice));
00584 }
00585
00609 void CBMAPIDECL
00610 cbm_pp_write(CBM_FILE HandleDevice, __u_char Byte)
00611 {
00612 FUNC_ENTER();
00613
00614 cbmarch_pp_write(HandleDevice, Byte);
00615
00616 FUNC_LEAVE();
00617 }
00618
00640 int CBMAPIDECL
00641 cbm_iec_poll(CBM_FILE HandleDevice)
00642 {
00643 FUNC_ENTER();
00644
00645 FUNC_LEAVE_INT(cbmarch_iec_poll(HandleDevice));
00646 }
00647
00648
00667 void CBMAPIDECL
00668 cbm_iec_set(CBM_FILE HandleDevice, int Line)
00669 {
00670 FUNC_ENTER();
00671
00672 cbmarch_iec_set(HandleDevice, Line);
00673
00674 FUNC_LEAVE();
00675 }
00676
00695 void CBMAPIDECL
00696 cbm_iec_release(CBM_FILE HandleDevice, int Line)
00697 {
00698 FUNC_ENTER();
00699
00700 cbmarch_iec_release(HandleDevice, Line);
00701
00702 FUNC_LEAVE();
00703 }
00704
00732 void CBMAPIDECL
00733 cbm_iec_setrelease(CBM_FILE HandleDevice, int Set, int Release)
00734 {
00735 FUNC_ENTER();
00736
00737 cbmarch_iec_setrelease(HandleDevice, Set, Release);
00738
00739 FUNC_LEAVE();
00740 }
00741
00768 int CBMAPIDECL
00769 cbm_iec_wait(CBM_FILE HandleDevice, int Line, int State)
00770 {
00771 FUNC_ENTER();
00772
00773 FUNC_LEAVE_INT(cbmarch_iec_wait(HandleDevice, Line, State));
00774 }
00775
00797 int CBMAPIDECL
00798 cbm_iec_get(CBM_FILE HandleDevice, int Line)
00799 {
00800 FUNC_ENTER();
00801 FUNC_LEAVE_INT((cbmarch_iec_poll(HandleDevice)&Line) != 0 ? 1 : 0);
00802 }
00803
00804
00805
00806
00807
00808
00844 int CBMAPIDECL
00845 cbm_device_status(CBM_FILE HandleDevice, __u_char DeviceAddress,
00846 void *Buffer, size_t BufferLength)
00847 {
00848 int retValue;
00849
00850 FUNC_ENTER();
00851
00852 DBG_ASSERT(Buffer && (BufferLength > 0));
00853
00854
00855
00856 retValue = 99;
00857
00858 if (Buffer && (BufferLength > 0))
00859 {
00860 char *bufferToWrite = Buffer;
00861
00862
00863
00864 bufferToWrite[--BufferLength] = '\0';
00865
00866
00867
00868 strncpy(bufferToWrite, "99, DRIVER ERROR,00,00\r", BufferLength);
00869
00870
00871
00872 if (cbmarch_talk(HandleDevice, DeviceAddress, 15) == 0)
00873 {
00874 int bytesRead = cbm_raw_read(HandleDevice, bufferToWrite, BufferLength);
00875
00876 DBG_ASSERT(bytesRead >= 0);
00877 DBG_ASSERT(((unsigned int)bytesRead) <= BufferLength);
00878
00879
00880
00881 bufferToWrite[bytesRead] = '\0';
00882
00883 cbmarch_untalk(HandleDevice);
00884 }
00885
00886 retValue = atoi(bufferToWrite);
00887 }
00888
00889 FUNC_LEAVE_INT(retValue);
00890 }
00891
00917 int CBMAPIDECL
00918 cbm_exec_command(CBM_FILE HandleDevice, __u_char DeviceAddress,
00919 const void *Command, size_t Size)
00920 {
00921 int rv;
00922
00923 FUNC_ENTER();
00924 rv = cbmarch_listen(HandleDevice, DeviceAddress, 15);
00925 if(rv == 0) {
00926 if(Size == 0) {
00927 Size = (size_t) strlen(Command);
00928 }
00929 rv = (size_t) cbmarch_raw_write(HandleDevice, Command, Size) != Size;
00930 cbmarch_unlisten(HandleDevice);
00931 }
00932
00933 FUNC_LEAVE_INT(rv);
00934 }
00935
00951 __u_char CBMAPIDECL
00952 cbm_parallel_burst_read(CBM_FILE HandleDevice)
00953 {
00954 FUNC_ENTER();
00955
00956 FUNC_LEAVE_UCHAR(cbmarch_parallel_burst_read(HandleDevice));
00957 }
00958
00974 void CBMAPIDECL
00975 cbm_parallel_burst_write(CBM_FILE HandleDevice, __u_char Value)
00976 {
00977 FUNC_ENTER();
00978
00979 cbmarch_parallel_burst_write(HandleDevice, Value);
00980
00981 FUNC_LEAVE();
00982 }
00983
01005 int CBMAPIDECL
01006 cbm_parallel_burst_read_track(CBM_FILE HandleDevice, __u_char *Buffer, unsigned int Length)
01007 {
01008 FUNC_ENTER();
01009
01010 FUNC_LEAVE_INT(cbmarch_parallel_burst_read_track(HandleDevice, Buffer, Length));
01011 }
01012
01034 int CBMAPIDECL
01035 cbm_parallel_burst_write_track(CBM_FILE HandleDevice, __u_char *Buffer, unsigned int Length)
01036 {
01037 FUNC_ENTER();
01038
01039 FUNC_LEAVE_INT(cbmarch_parallel_burst_write_track(HandleDevice, Buffer, Length));
01040 }