//*************************************************************************** //* * //* BOOL close() * //* * //* This closes the ASPI library and ASPI router driver and frees * //* the memory allocated for the data buffer. //* Returns: * //* TRUE - Success * //* FALSE - Unsuccessful closing of library and driver * //* * //* Preconditions: init() should be called successfully before * //* * //*************************************************************************** BOOL scsiObj::close() { BOOL success; ULONG rc; success=closeSemaphore(); // call closeSemaphore member function if (!success) { printf("closeSemaphore() unsuccessful.\n"); return FALSE; } success=closeDriver(); // call closeDriver member function if (!success) { return FALSE; printf("closeDriver() unsucessful.\n"); } rc = DosFreeMem(buffer); if (rc) { printf("DosFreeMem unsuccessful. return code: %ld\n", rc); return FALSE; } return TRUE; }
static int performTest(void) { int rc = 0; HANDLE hDevice = openDriver(); if (hDevice != INVALID_HANDLE_VALUE) closeDriver(hDevice); else printf("openDriver failed!\n"); return rc; }
//_______________________________________________________________________ int main (int argc, char *argv[]) { DrvMemPtr mem = GetData(); uid_t uid = getuid (); if (argc != 2) usage (argv[0]); CheckMidiShare(); setuid (name_to_uid ("root")); mem->devId = openDev (argv[1]); SetupMidi (argv[1], mem); ThreadCreate (mem); run (mem, argv[1]); closeDriver (mem); setuid (uid); return 0; }
int performTest(void) { int rc = 0; HANDLE hDevice = openDriver(); if (hDevice != INVALID_HANDLE_VALUE) { DWORD cbReturned; closeDriver(hDevice); } else { printf("openDriver failed!\n"); } return rc; }
RESPONSECODE IFDHCloseChannel ( DWORD Lun ) { /* This function should close the reader communication channel for the particular reader. Prior to closing the communication channel the reader should make sure the card is powered down and the terminal is also powered down. returns: IFD_SUCCESS IFD_COMMUNICATION_ERROR */ /* TODO: power down the card */ //int readerNum = (Lun & 0xFFFF0000) >> 16; closeDriver(Lun); return IFD_SUCCESS; }
//_______________________________________________________________________ static void FatalError (const char *msg) { fprintf (stderr, "%s\n", msg); closeDriver (GetData()); exit (1); }
static BOOL handleCommand(char line[]) { BOOL ret = TRUE; if (strcmp(line, "q") == 0) ret = FALSE; else if (strcmp(line, "o") == 0 && gDeviceHandle == INVALID_HANDLE_VALUE) openDriver(); else if (strcmp(line, "c") == 0 && gDeviceHandle != INVALID_HANDLE_VALUE) closeDriver(); else if (strcmp(line, "g") == 0 && gDeviceHandle != INVALID_HANDLE_VALUE && gDeviceListSize == 0) getDeviceList(); else if (strcmp(line, "p") == 0 && gDeviceHandle != INVALID_HANDLE_VALUE && gDeviceListSize > 0) printDeviceList(); else if (strcmp(line, "r") == 0 && gDeviceHandle != INVALID_HANDLE_VALUE && gDeviceListSize > 0) releaseDeviceList(); else if (line[0] == 'm' && gDeviceHandle != INVALID_HANDLE_VALUE && gDeviceListSize > 0) sendControlRequest(line + 1); else if (line[0] == 'a' && gDeviceHandle != INVALID_HANDLE_VALUE && gDeviceListSize > 0) sendAapRequest(line + 1); else if (line[0] == 'c' && gDeviceHandle != INVALID_HANDLE_VALUE && gDeviceListSize > 0) requestConfigurationDescriptor(line + 1); else if (line[0] == 'o' && gDeviceHandle != INVALID_HANDLE_VALUE && gDeviceListSize > 0) getActiveConfigValue(line + 1); else if (line[0] == 's' && gDeviceHandle != INVALID_HANDLE_VALUE && gDeviceListSize > 0) setActiveConfigValue(line + 1); else if (line[0] == 'i' && gDeviceHandle != INVALID_HANDLE_VALUE && gDeviceListSize > 0) performInterfaceOperation(line + 1); else if (line[0] == 'r' && gDeviceHandle != INVALID_HANDLE_VALUE && gDeviceListSize > 0) resetDevice(line + 1); else if (line[0] == 'k' && gDeviceHandle != INVALID_HANDLE_VALUE && gDeviceListSize > 0) performKernelAttachOperation(line + 1); else if (line[0] == 'b' && gDeviceHandle != INVALID_HANDLE_VALUE && gDeviceListSize > 0) startAAPBulkTransfer(line + 1); else if (line[0] == 'h' && gDeviceHandle != INVALID_HANDLE_VALUE && gDeviceListSize > 0) performHaltOperation(line + 1); else printf("Unknown command '%s'\n", line); return ret; }
K runtest(K opv, K ecxv, K eaxv, K edxv, K testCount) { struct MsrInOut s_pmc_reset[9]; struct MsrInOut s_pmc_read[9]; unsigned long long s_ffc_fixed[FFC_COUNT]; unsigned long long s_pmc_fixed[PMC_COUNT]; struct MsrInOut *ptr; int i; long long count; void *handle; char *error; K result; void (*execute_test)(void (s1)(void), void(s2)(void)); // dynamically load the test library handle = dlopen("libtest.so", RTLD_NOW); //handle = dlopen("libtest.so", RTLD_LAZY); if (!handle) { krr(dlerror()); // signal exception to kdb+ return (K)0; } execute_test = dlsym(handle, "execute_test"); if ((error = dlerror()) != NULL) { krr("While locating symbof 'execute_test'"); return (K)0; } // zero the fixed-cost accumulators for (i = 0 ; i < PMC_COUNT ; i++) s_pmc_fixed[i] = 0; for (i = 0 ; i < FFC_COUNT ; i++) s_ffc_fixed[i] = 0; // set the global (static) pointers ffc_fixed = s_ffc_fixed; pmc_fixed = s_pmc_fixed; pmc_reset = s_pmc_reset; pmc_read = s_pmc_read; ptr = pmc_cfg = (struct MsrInOut*)malloc((opv->n + 1) * sizeof(struct MsrInOut)); if (pmc_cfg == NULL) { orr("malloc"); return (K)0; } record_reset(); record_read(); // record the PMC instructions to memory count = opv->n; for (i = 0 ; i < count ; i++) { wr_msrio(ptr++, kI(opv)[i], kI(ecxv)[i], kI(eaxv)[i], kI(edxv)[i]); } msr_wr_stop(ptr++); loadDriver(); if (fd == -1) { return (K)0; } result = run_test(execute_test, testCount->i); // disable and zero the PMC MSRs ioctl(fd, IOCTL_MSR_CMDS, (long long)s_pmc_reset); // return the dynamically allocated memory free(pmc_cfg); // close the dyn-lib function handle dlclose(handle); // close the MSR driver closeDriver(fd); return result; }