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

setrelease.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-2004 Michael Klein <michael(dot)klein(at)puffin(dot)lb(dot)shuttle(dot)de>
00008  *  Copyright 2001-2004 Spiro Trikaliotis
00009  *
00010  */
00011 
00023 #include <wdm.h>
00024 #include "cbm_driver.h"
00025 #include "i_iec.h"
00026 
00051 NTSTATUS
00052 cbmiec_iec_setrelease(IN PDEVICE_EXTENSION Pdx, IN USHORT Set, IN USHORT Release)
00053 {
00054     NTSTATUS ntStatus;
00055 
00056     FUNC_ENTER();
00057 
00058     FUNC_PARAM((DBG_PREFIX "set = 0x%02x, release = 0x%02x", Set, Release));
00059 
00060     ntStatus = STATUS_SUCCESS;
00061 
00062     DBG_ASSERT((Set & Release) == 0);
00063 
00064     // Set the correct line as given by the call
00065 
00066     if ( (Set & ~(IEC_LINE_DATA | IEC_LINE_CLOCK | IEC_LINE_ATN | IEC_LINE_RESET))
00067         || (Release & ~(IEC_LINE_DATA | IEC_LINE_CLOCK | IEC_LINE_ATN | IEC_LINE_RESET)))
00068     {
00069         // there was some bit set that is not recognized, return
00070         // with an error
00071         ntStatus = STATUS_INVALID_PARAMETER;
00072     }
00073     else
00074     {
00075         ULONG set_mask = 0;
00076         ULONG release_mask = 0;
00077 
00078 #define SET_RELEASE_LINE(_LineName, _PPName) \
00079         if (Set     & IEC_LINE_##_LineName) { set_mask     |= PP_##_PPName##_OUT; } \
00080         if (Release & IEC_LINE_##_LineName) { release_mask |= PP_##_PPName##_OUT; }
00081 
00082         SET_RELEASE_LINE(DATA,  DATA);
00083         SET_RELEASE_LINE(CLOCK, CLK);
00084         SET_RELEASE_LINE(ATN,   ATN);
00085         SET_RELEASE_LINE(RESET, RESET);
00086 
00087 #ifdef TEST_BIDIR
00088 
00089         #define PP_BIDIR_OUT   PP_LP_BIDIR
00090         #define IEC_LINE_BIDIR PP_BIDIR_OUT
00091 
00092         SET_RELEASE_LINE(BIDIR, BIDIR);
00093 
00094         #undef PP_BIDIR_OUT
00095         #undef IEC_LINE_BIDIR
00096 
00097 #endif // #ifdef TEST_BIDIR
00098 
00099 #undef SET_RELEASE_LINE
00100 
00101         CBMIEC_SET_RELEASE(set_mask, release_mask);
00102 
00103     }
00104 
00105     FUNC_LEAVE_NTSTATUS(ntStatus );
00106 }

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