void cbmarch_unlock(CBM_FILE HandleDevice) { FUNC_ENTER(); FUNC_LEAVE(); }
void cbmarch_iec_release(CBM_FILE HandleDevice, int Line) { FUNC_ENTER(); cbmarch_iec_setrelease(HandleDevice, 0, Line); FUNC_LEAVE(); }
/*! \brief Release the IEC bus This function releases the IEC bus. \param Pdx Pointer to the device extension. \return If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it returns one of the error status values. */ VOID cbmiec_release_bus(IN PDEVICE_EXTENSION Pdx) { FUNC_ENTER(); CBMIEC_RELEASE(PP_RESET_OUT | PP_ATN_OUT | PP_DATA_OUT | PP_CLK_OUT); FUNC_LEAVE(); }
static VOID VDDBlockHandler(VOID) { FUNC_ENTER(); vdd_cbmfile_closeall(); FUNC_LEAVE(); }
void cbmarch_unlock(CBM_FILE HandleDevice) { FUNC_ENTER(); cbm_ioctl(HandleDevice, CBMCTRL(PARPORT_UNLOCK), NULL, 0, NULL, 0); FUNC_LEAVE(); }
VOID VDDRegisterInit(VOID) { FUNC_ENTER(); setCF(0); FUNC_LEAVE(); }
void CBMAPIDECL opencbm_plugin_unlock(CBM_FILE HandleDevice) { FUNC_ENTER(); cbm_ioctl(HandleDevice, CBMCTRL(PARPORT_UNLOCK), NULL, 0, NULL, 0); FUNC_LEAVE(); }
void cbmarch_pp_write(CBM_FILE HandleDevice, __u_char Byte) { FUNC_ENTER(); vicepause(); vicewriteregister(reg_a, Byte); send_and_wait(addr_pp_write, data_pp_write, sizeof(data_pp_write)); FUNC_LEAVE(); }
static void fastschedule_start(void) { FUNC_ENTER(); if (timeBeginPeriod(1) != TIMERR_NOERROR) { DBG_WARN((DBG_PREFIX "Unable to decrease scheduling period.")); } FUNC_LEAVE(); }
static void fastschedule_stop(void) { FUNC_ENTER(); if (timeEndPeriod(1) != TIMERR_NOERROR) { DBG_WARN((DBG_PREFIX "Unable to restore scheduling period.")); } FUNC_LEAVE(); }
/* Create test data, returns 0 if no memory */ static int fbdev_test_data_new (blts_fbdev_data *data) { size_t lut_sz = (data->device->variant_info.xres * data->device->variant_info.yres); FUNC_ENTER(); __u32 *lut = malloc (lut_sz * sizeof (__u32)); if (!lut) { BLTS_ERROR ("OOM!\n"); return 0; } __u32 x,y; __u32 line_start, x_offset; __u32 bpp_bytes = data->device->variant_info.bits_per_pixel >> 3; /* write offsets to table*/ line_start = (data->device->fixed_info.line_length * data->device->variant_info.yoffset + bpp_bytes * data->device->variant_info.xoffset); __u32 i = 0; for (y = 0; y < data->device->variant_info.yres; ++y) { x_offset = 0; for (x = 0; x < data->device->variant_info.xres; ++x) { lut[i++] = line_start + x_offset; x_offset += bpp_bytes; } line_start += data->device->fixed_info.line_length; } /* shuffle (this is the Knuth shuffle, actually) */ __u32 k, tmp, n = lut_sz; while (n) { k = rand() % n; n--; tmp = lut[n]; lut[n] = lut[k]; lut[k] = tmp; } data->shuffle_lut = lut; FUNC_LEAVE(); return 1; }
void cbmarch_parallel_burst_write(CBM_FILE HandleDevice, __u_char Value) { CBMT_PARBURST_PWRITE_IN parameter; FUNC_ENTER(); parameter.Byte = Value; cbm_ioctl(HandleDevice, CBMCTRL(PARBURST_WRITE), ¶meter, sizeof(parameter), NULL, 0); FUNC_LEAVE(); }
void CBMAPIDECL opencbm_plugin_iec_set(CBM_FILE HandleDevice, int Line) { CBMT_IEC_SET_IN parameter; FUNC_ENTER(); parameter.Line = (UCHAR) Line; cbm_ioctl(HandleDevice, CBMCTRL(IEC_SET), ¶meter, sizeof(parameter), NULL, 0); FUNC_LEAVE(); }
void cbmarch_pp_write(CBM_FILE HandleDevice, __u_char Byte) { CBMT_PP_WRITE_IN parameter; FUNC_ENTER(); parameter.Byte = Byte; cbm_ioctl(HandleDevice, CBMCTRL(PP_WRITE), ¶meter, sizeof(parameter), NULL, 0); FUNC_LEAVE(); }
void cbmarch_iec_release(CBM_FILE HandleDevice, int Line) { CBMT_IEC_RELEASE_IN parameter; FUNC_ENTER(); parameter.Line = (UCHAR) Line; cbm_ioctl(HandleDevice, CBMCTRL(IEC_RELEASE), ¶meter, sizeof(parameter), NULL, 0); FUNC_LEAVE(); }
void CBMAPIDECL opencbm_plugin_pp_write(CBM_FILE HandleDevice, unsigned char Byte) { CBMT_PP_WRITE_IN parameter; FUNC_ENTER(); parameter.Byte = Byte; cbm_ioctl(HandleDevice, CBMCTRL(PP_WRITE), ¶meter, sizeof(parameter), NULL, 0); FUNC_LEAVE(); }
void cbmarch_iec_setrelease(CBM_FILE HandleDevice, int Set, int Release) { CBMT_IEC_SETRELEASE_IN parameter; FUNC_ENTER(); parameter.State = (UCHAR) Set; parameter.Line = (UCHAR) Release; cbm_ioctl(HandleDevice, CBMCTRL(IEC_SETRELEASE), ¶meter, sizeof(parameter), NULL, 0); FUNC_LEAVE(); }
VOID CbmInstallUpdate(VOID) { CBM_FILE HandleDevice; FUNC_ENTER(); if (cbmarch_driver_open(&HandleDevice, 0) == 0) { cbm_ioctl(HandleDevice, CBMCTRL(UPDATE), NULL, 0, NULL, 0); cbmarch_driver_close(HandleDevice); } FUNC_LEAVE(); }
static void send_and_wait(const unsigned int addr, const unsigned char *buffer, int size) { FUNC_ENTER(); vicewritememory(addr, size, buffer); vicewriteregister(reg_pc, addr); vicewriteregister_when_at(0x2000); vicetrap(0x2000); viceresume(); vicewaittrap(); FUNC_LEAVE(); }
VOID CbmOutputDebuggingBuffer(VOID) { #define OUTPUT_BUFFER_LEN 0x20000 CHAR *buffer; CBM_FILE HandleDevice; FUNC_ENTER(); buffer = malloc(OUTPUT_BUFFER_LEN); if (buffer && cbmarch_driver_open(&HandleDevice, 0) == 0) { PCHAR p = buffer; PCHAR endLine; cbm_ioctl(HandleDevice, CBMCTRL(I_READDBG), NULL, 0, buffer, OUTPUT_BUFFER_LEN); cbmarch_driver_close(HandleDevice); printf("Output of the debugging buffer:\n\n"); do { endLine = strchr(p, 13); if (endLine) { *endLine = 0; } printf("%s", p); p = endLine + 1; } while (endLine); } if (buffer) { free(buffer); } FUNC_LEAVE(); }
/*! \brief DPC function for releasing cbmiec_wait_for_listener() \param Dpc Pointer to the KDPC \param Fdo Pointer to the FDO \param Irp Pointer to the Irp. UNUSED. \param Context Caller-supplied Context. UNUSED. \param Result Pointer to the variable which will hold the return value. After return, it will contain 1 if there was an EOI, 0 otherwise. \return If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it returns one of the error status values. */ VOID cbmiec_dpc(IN PKDPC Dpc, IN PDEVICE_OBJECT Fdo, IN PIRP Irp, IN PVOID Context) { PDEVICE_EXTENSION pdx; FUNC_ENTER(); UNREFERENCED_PARAMETER(Dpc); UNREFERENCED_PARAMETER(Irp); UNREFERENCED_PARAMETER(Context); DBG_DPC((DBG_PREFIX "DPC called")); pdx = Fdo->DeviceExtension; // Set the event that we are ready to quit cbmiec_wait_for_listener() DBG_IRQL( <= DISPATCH_LEVEL); KeSetEvent(&pdx->EventWaitForListener, IO_SOUND_INCREMENT, FALSE); FUNC_LEAVE(); }
static void read_line_status(CBM_FILE fd) { int data, clock, atn, reset, pp; FUNC_ENTER(); data = cbm_iec_get(fd, IEC_DATA); clock = cbm_iec_get(fd, IEC_CLOCK); atn = cbm_iec_get(fd, IEC_ATN); reset = cbm_iec_get(fd, IEC_RESET); pp = cbm_pp_read(fd); DBG_PRINT((DBG_PREFIX "READ: DATA = %s, CLOCK = %s, ATN = %s, RESET = %s, PP = $%02x", data ? "TRUE " : "FALSE", clock ? "TRUE " : "FALSE", atn ? "TRUE " : "FALSE", reset ? "TRUE " : "FALSE", pp)); FUNC_LEAVE(); }
/*! \brief Cancel routine if we are waiting This function is the cancel routine while a IRP is in the cbmiec_wait_for_listener() function. \param Fdo Pointer to the Fdo \param Irp Pointer to the IRP which is to be cancelled. This function does not cancel the IRP itself, but it only releases cbmiec_wait_for_listener(). */ static VOID WaitCancelRoutine(IN PDEVICE_OBJECT Fdo, IN PIRP Irp) { PDEVICE_EXTENSION pdx; FUNC_ENTER(); pdx = Fdo->DeviceExtension; // We do not need the cancel spin lock anymore DBG_DPC((DBG_PREFIX "Cancelling IRP 0x%p", Irp)); DBG_IRQL( == DISPATCH_LEVEL); IoReleaseCancelSpinLock(Irp->CancelIrql); // Just release cbmiec_wait_for_listener(), but do NOT cancel the IRP! // This is left for cbmiec_wait_for_listener() as an exercise... DBG_IRQL( <= DISPATCH_LEVEL); KeSetEvent(&pdx->EventWaitForListener, IO_NO_INCREMENT, FALSE); FUNC_LEAVE(); }
void cbmarch_iec_setrelease(CBM_FILE HandleDevice, int Set, int Release) { __u_char set = 0; __u_char release = 0; FUNC_ENTER(); DBG_ASSERT((Set & Release) == 0); // DbgOut(""); // DbgOut("setrelease: Mask = %u, Line = %u", Set, Release); cbmarch_iec_poll(HandleDevice); if (Set & IEC_DATA) set |= VICE_DATA_OUT; if (Set & IEC_CLOCK) set |= VICE_CLK_OUT; if (Set & IEC_ATN) set |= VICE_ATN_OUT; if (Release & IEC_DATA) release |= VICE_DATA_OUT; if (Release & IEC_CLOCK) release |= VICE_CLK_OUT; if (Release & IEC_ATN) release |= VICE_ATN_OUT; if (set || release) { // DbgOut("iec_setrelease = set = $%02x, release = $%02x", set, release); vicepause(); vicewriteregister(reg_a, release ^ 0xff); vicewriteregister(reg_x, set); send_and_wait(addr_iec_setrelease, data_iec_setrelease, sizeof(data_iec_setrelease)); } cbmarch_iec_poll(HandleDevice); FUNC_LEAVE(); }
VOID VDDDispatch(VOID) { FUNCTIONCODE functioncode; CBM_FILE cbmfile; BOOLEAN error; FUNC_ENTER(); functioncode = getDL(); error = FALSE; // convert to BX value into a CBM_FILE switch (functioncode) { case FC_VDD_USLEEP: case FC_DRIVER_OPEN: case FC_GET_DRIVER_NAME: // FC_VDD_USLEEP, FC_DRIVER_OPEN and FC_GET_DRIVER_NAME are special, // they do not have a BX input. break; default: cbmfile = vdd_cbmfile_get(getBX()); if (cbmfile == INVALID_HANDLE_VALUE) { DBG_ERROR((DBG_PREFIX "invalid BX given: %04x", getBX())); error = TRUE; } break; } if (!error) { switch (functioncode) { case FC_DRIVER_OPEN: error = vdd_driver_open(); break; case FC_DRIVER_CLOSE: error = vdd_driver_close(cbmfile); break; case FC_LISTEN: error = vdd_listen(cbmfile); break; case FC_TALK: error = vdd_talk(cbmfile); break; case FC_OPEN: error = vdd_open(cbmfile); break; case FC_CLOSE: error = vdd_close(cbmfile); break; case FC_RAW_READ: error = vdd_raw_read(cbmfile); break; case FC_RAW_WRITE: error = vdd_raw_write(cbmfile); break; case FC_UNLISTEN: error = vdd_unlisten(cbmfile); break; case FC_UNTALK: error = vdd_untalk(cbmfile); break; case FC_GET_EOI: error = vdd_get_eoi(cbmfile); break; case FC_CLEAR_EOI: error = vdd_clear_eoi(cbmfile); break; case FC_RESET: error = vdd_reset(cbmfile); break; case FC_PP_READ: error = vdd_pp_read(cbmfile); break; case FC_PP_WRITE: error = vdd_pp_write(cbmfile); break; case FC_IEC_POLL: error = vdd_iec_poll(cbmfile); break; case FC_IEC_GET: error = vdd_iec_get(cbmfile); break; case FC_IEC_SET: error = vdd_iec_set(cbmfile); break; case FC_IEC_RELEASE: error = vdd_iec_release(cbmfile); break; case FC_IEC_SETRELEASE: error = vdd_iec_setrelease(cbmfile); break; case FC_IEC_WAIT: error = vdd_iec_wait(cbmfile); break; case FC_UPLOAD: error = vdd_upload(cbmfile); break; case FC_DEVICE_STATUS: error = vdd_device_status(cbmfile); break; case FC_EXEC_COMMAND: error = vdd_exec_command(cbmfile); break; case FC_IDENTIFY: error = vdd_identify(cbmfile); break; case FC_IDENTIFY_XP1541: error = vdd_identify_xp1541(cbmfile); break; case FC_GET_DRIVER_NAME: error = vdd_get_driver_name(); break; case FC_VDD_USLEEP: error = vdd_usleep(); break; case FC_VDD_INSTALL_IOHOOK: error = vdd_install_iohook(cbmfile); break; case FC_VDD_UNINSTALL_IOHOOK: error = vdd_uninstall_iohook(cbmfile); break; default: // this function is not implemented: DBG_ERROR((DBG_PREFIX "unknown function code in DL: %02x", functioncode)); error = TRUE; break; } } setCF(error ? 1 : 0); FUNC_LEAVE(); }
VOID cbm_init_registry(IN PUNICODE_STRING RegistryPath, IN PDEVICE_EXTENSION Pdx) { NTSTATUS ntStatus; FUNC_ENTER(); ntStatus = STATUS_SUCCESS; if (RegistryPath) { // Copy the registry path to the location DBG_ASSERT(ServiceKeyRegistryPath.Buffer == 0); // Allocate memory for the registry path ServiceKeyRegistryPath.Buffer = ExAllocatePoolWithTag(PagedPool, RegistryPath->Length, MTAG_SERVKEY); // Copy the registry path into the variable if (ServiceKeyRegistryPath.Buffer) { ServiceKeyRegistryPath.MaximumLength = ServiceKeyRegistryPath.Length = RegistryPath->Length; RtlCopyUnicodeString(&ServiceKeyRegistryPath, RegistryPath); } else { // No memory could be allocateed, mark the // length of the string appropriately ServiceKeyRegistryPath.MaximumLength = ServiceKeyRegistryPath.Length = 0; } } // If there is some registry path given, read from that if (ServiceKeyRegistryPath.Length != 0 && ServiceKeyRegistryPath.Buffer != NULL) { HANDLE hKey; // Open the registry for reading ntStatus = cbm_registry_open_for_read(&hKey, &ServiceKeyRegistryPath); if (NT_SUCCESS(ntStatus)) { // the cable type ULONG iecCable = IEC_CABLETYPE_AUTO; #if DBG // In debugging versions, make sure the DebugFlags // are read from the registry cbm_registry_read_ulong(hKey, L"DebugFlags", &DbgFlags); #endif // #if DBG if (Pdx) { // // update the cable type // cbm_registry_read_ulong(hKey, L"CableType", &iecCable); cbmiec_set_cabletype(Pdx, iecCable); // // update if we are requested to permanently lock the parallel port // iecCable = 1; // default is: Yes, lock cbm_registry_read_ulong(hKey, L"PermanentlyLock", &iecCable); Pdx->ParallelPortLock = iecCable ? TRUE : FALSE; } // initialize the libiec library cbmiec_global_init(&hKey); // we're done with the registry cbm_registry_close(hKey); } else { // An error occured. // In this case, initialize the libiec with defaults cbmiec_global_init(NULL); } } else { // No registry path is given. // In this case, initialize the libiec with defaults cbmiec_global_init(NULL); } // // If requested by the registry, lock the parallel port // if (Pdx && Pdx->ParallelPortLock && Pdx->ParallelPortIsLocked == FALSE) { cbm_lock_parport(Pdx); } FUNC_LEAVE(); }
static int v4l2_case_measure(void* user_ptr, int test_num) { FUNC_ENTER(); int max_width; int max_height; v4l2_data* data = (v4l2_data*)user_ptr; BLTS_DEBUG("Test number %i:\n", test_num); if(!open_device (data->device)) { BLTS_DEBUG("Can't open device %s\n", data->device->dev_name); FUNC_LEAVE(); return -1; } if(init_device (data->device, MAX_WIDTH, MAX_HEIGHT)) { BLTS_DEBUG("Maximum resolution is: %ix%i\n", data->device->format.fmt.pix.width, data->device->format.fmt.pix.height); BLTS_DEBUG("Measuring FPS on maximum resolution\n"); max_width = data->device->format.fmt.pix.width; max_height = data->device->format.fmt.pix.height; BLTS_DEBUG("-----------------------\n"); BLTS_DEBUG("%ix%i resolution\n", max_width, max_height); BLTS_DEBUG("-----------------------\n"); if(!start_capturing (data->device)) goto err; mainloop (data->device, LOOPS); stop_capturing (data->device); uninit_device (data->device); close_device (data->device); } else { BLTS_DEBUG("Can't initialize device\n"); goto err; } BLTS_DEBUG("Stepping down resolutions and calculating FPS\n"); int step_size_x, step_size_y, i, x, y; step_size_x = max_width / 10; step_size_y = max_height / 10; for(i=1; i<8; i++) { x = max_width - step_size_x * i; y = max_height - step_size_y * i; BLTS_DEBUG("-----------------------\n"); BLTS_DEBUG("%ix%i resolution\n", x, y); BLTS_DEBUG("-----------------------\n"); if(!open_device (data->device)) goto err; if(init_device (data->device, x, y)) { BLTS_DEBUG("Resolution is: %ix%i\n", x, y); if(!start_capturing (data->device)) goto err; if(!mainloop (data->device, LOOPS)) goto err; stop_capturing (data->device); uninit_device (data->device); } else { BLTS_DEBUG("Can't initialize device\n"); goto err; } close_device (data->device); } FUNC_LEAVE(); return 0; err: stop_capturing(data->device); uninit_device(data->device); close_device(data->device); FUNC_LEAVE(); return -1; }