-int pp_transfer(WD_TRANSFER *tr, int fd, unsigned int request, unsigned char *wdioctl) {
- int ret = 0;
- unsigned long port = (unsigned long)tr->dwPort;
- unsigned char val;
- static unsigned char last_pp_write = 0;
-
-#ifdef JTAGKEY
- /* FIXME: Config file and mor intelligent mapping! */
- if (ppbase == 0x30)
- return jtagkey_transfer(tr, fd, request, ppbase, ecpbase, 1);
-#endif
-
- DPRINTF("dwPort: 0x%lx, cmdTrans: %lu, dwbytes: %ld, fautoinc: %ld, dwoptions: %ld\n",
- (unsigned long)tr->dwPort, tr->cmdTrans, tr->dwBytes,
- tr->fAutoinc, tr->dwOptions);
-
- val = tr->Data.Byte;
-
-#ifdef DEBUG
- if (tr->cmdTrans == 13)
- DPRINTF("write byte: %d\n", val);
-#endif
-
-#ifndef NO_WINDRVR
- ret = (*ioctl_func) (fd, request, wdioctl);
-#else
- if (parportfd < 0)
- return ret;
-
- if (port == ppbase + PP_DATA) {
- DPRINTF("data port\n");
- switch(tr->cmdTrans) {
- case PP_READ:
- ret = 0; /* We don't support reading of the data port */
- break;
-
- case PP_WRITE:
- ret = ioctl(parportfd, PPWDATA, &val);
- last_pp_write = val;
- break;
-
- default:
- fprintf(stderr,"!!!Unsupported TRANSFER command: %lu!!!\n", tr->cmdTrans);
- ret = -1;
- break;
- }
- } else if (port == ppbase + PP_STATUS) {
- DPRINTF("status port (last write: %d)\n", last_pp_write);
- switch(tr->cmdTrans) {
- case PP_READ:
- ret = ioctl(parportfd, PPRSTATUS, &val);
-#ifdef FORCE_PC3_IDENT
- val &= 0x5f;
- if (last_pp_write & 0x40)
- val |= 0x20;
- else
- val |= 0x80;
-#endif
- break;
-
- case PP_WRITE:
- ret = 0; /* Status Port is readonly */
- break;
-
- default:
- fprintf(stderr,"!!!Unsupported TRANSFER command: %lu!!!\n", tr->cmdTrans);
- ret = -1;
- break;
- }
- } else if (port == ppbase + PP_CONTROL) {
- DPRINTF("control port\n");
- switch(tr->cmdTrans) {
- case PP_READ:
- ret = ioctl(parportfd, PPRCONTROL, &val);
- break;
-
- case PP_WRITE:
- ret = ioctl(parportfd, PPWCONTROL, &val);
- break;
-
- default:
- fprintf(stderr,"!!!Unsupported TRANSFER command: %lu!!!\n", tr->cmdTrans);
- ret = -1;
- break;
- }
- } else if ((port == ecpbase + PP_ECP_CFGA) && ecpbase) {
- DPRINTF("ECP_CFGA port\n");
- } else if ((port == ecpbase + PP_ECP_CFGB) && ecpbase) {
- DPRINTF("ECP_CFGB port\n");
- } else if ((port == ecpbase + PP_ECP_ECR) && ecpbase) {
- DPRINTF("ECP_ECR port\n");
- } else {
- DPRINTF("access to unsupported address range!\n");
- ret = 0;
- }
-
- tr->Data.Byte = val;
-#endif
-
- DPRINTF("dwPortReturn: 0x%lx, cmdTrans: %lu, dwbytes: %ld, fautoinc: %ld, dwoptions: %ld\n",
- (unsigned long)tr->dwPort, tr->cmdTrans, tr->dwBytes,
- tr->fAutoinc, tr->dwOptions);
-#ifdef DEBUG
- if (tr->cmdTrans == 10)
- DPRINTF("read byte: %d\n", tr->Data.Byte);
-#endif
-
- return ret;
-}
-