Hy friends
I´m trying to read a USB Touch Screen on DOS. I wrote the code with the Turbo C++ 3.0 and it works very well, but when i try to do the same with the Open Watcom using the Causeway DOS Extender, the program crash when USBUHCIL try notify my program using the call back routine when i plug-off the USB cable. Follow what i did:
The following routine, works very well, and i get see the correct value on the statusDriver variable:
void Int14TestInstall(void)
{
union REGS regs; //CPU Registers
struct SREGS sregs;
regs.w.ax = I14AXInstallCheck; //AX = Function (Installation Check)
regs.w.bx = I14BXInput; //BX = Correct Value
regs.w.cx = I14CXInput; //CX = Correct Value
memset(&sregs,0,sizeof(sregs));
int386x(0x14,®s,®s,&sregs);
if ((regs.w.ax != 0x0000) || (regs.w.bx != I14CXInput) || (regs.w.cx != I14BXInput))
statusDriver=0; //Err
else
statusDriver=1; //Ok
}
Bellow, we can see the call back routine. For me is enough the variable to receive the value "1" (only for tests, of course):
void interrupt callBackRoutine(void) {
statusCallBack=1;
}
Bellow, is the code that realize the interface own registration:
struct Int14RequestStruc Int14Request;
struct Int14RequestStruc far *Int14RequestPtr;
Here, i allocated conventional memory (first mega) to the Int14RequestStruct:
memset(&sregs,0,sizeof(sregs));
regs.w.ax=0x0ff21;
regs.w.bx=0x0010;
int386x(0x31,®s,®s,&sregs);
segmentInt14Request=regs.w.ax;
selectorInt14Request=regs.w.dx;
Int14RequestPtr=(struct Int14RequestStruc far *)MK_FP(selectorInt14Request,0);
Now, i prepare the request:
Int14RequestPtr->I14RRequestType = I14RRTRegIntfOwner;
Int14RequestPtr->I14RHostIndex = 255; //Todos
Int14RequestPtr->I14RDeviceAddress = 0; //Novo
Int14RequestPtr->I14RVendorID = 0; //Nao importa o vendedor
Int14RequestPtr->I14RProductID = 0; //Nao importa o ID do produto
Int14RequestPtr->I14RDvcClass = 255; //Nao importa qual
Int14RequestPtr->I14RDvcSubClass = 255; //Nao importa
Int14RequestPtr->I14RDvcProtocol = 255; //Nao importa
Int14RequestPtr->I14RIntfClass = 255;
Int14RequestPtr->I14RIntfSubClass = 255;
Int14RequestPtr->I14RIntfProtocol = 255;
Int14RequestPtr->I14RCallBackAddrOff=(unsigned short) FP_OFF(callBackRotine);
Int14RequestPtr->I14RCallBackAddrSeg=(unsigned short) FP_SEG(callBackRotine);
Int14RequestPtr->I14RUserPktID = 88;
Now, i set-up a real-mode call. The call is correct, because if i put "zeros" on SEG and OFFSET of call back address, the API return the error 0x21 on statusRegistering variable:
struct rminfo rmi;
memset(&rmi,0,sizeof(rmi));
rmi.EAX=I14AXDoFunction;
rmi.EBX=I14BXInput;
rmi.ECX=I14CXInput;
rmi.DS=segmentInt14Request;
rmi.EDX=0;
regs.w.ax=0x0ff01;
regs.h.bl=0x14;
sregs.es=FP_SEG(&rmi);
regs.x.edi=FP_OFF(&rmi);
int386x(0x31,®s,®s,&sregs);
statusRegistering=rmi.EAX;
Every thing seens to work, but when i pull up the USB connector, the computer CRASH. I don´t know what can be anymore.
Could someone help me ?
Thanks a lot
Fernando Branquinho (from Brazil)