Xref: utzoo alt.msdos.programmer:2055 comp.os.msdos.programmer:585 Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uunet!matrix!venkat From: venkat@matrix.UUCP (D Venkatrangan) Newsgroups: alt.msdos.programmer,comp.os.msdos.programmer Subject: Propagating Device Driver error status into C runtime errno variable. Keywords: DOS, Device Driver Message-ID: <163@matrix.UUCP> Date: 20 Aug 90 21:36:31 GMT Distribution: na Organization: Matrix Computer Systems, Nashua, NH Lines: 34 Greetings MS-DOS programmers: I am writing an installable device driver for DOS 3.0. It is a character device which will support read, write and close calls. I.e., INT 21h functions AH=3Eh, AH=3Fh and AH=40h. In the case where there are no errors, I have it working correctly. The strategy routine saves ES and BX in current code segment. Then the interrpt routine gets this saved address and calls the appropriate function. When it is done, es:[bx].status is set to the DONE (0x100h) value. If there are errors however, I would like to make sure that one out of a large number of error numbers is set. Basically, I want to make sure that the code that did the INT 21h gets a Carry Flag that is set and an error code that is set in AX to a particular error. But setting the Carry Flag before returning from the interrupt strategy routine does not seem to help. It looks like a lot of processing happens after the return from the driver's interrupt routine up to the IRET from the int 21h. During this processing the carry flag gets cleared. Also, the C runtime library functions read(), write() and close() which originally issued the INT 21h appear to expect the Carry Flag to be set, with an error number only in AH with AL set to zero. If this is the case, the C runtime implementation of read() etc. transfers the error value from AH into the errno variable. Who sets the Carry Flag for the return from int21h and what should the driver's interrupt routine do for that flag to be set? Setting es:[bx].status to 8000h OR'ed with a byte of error code in the range 0 to 0Fh causes a message such as "Write Fault Error on Device XXX" to be displayed. Instead, I would like to quietly return to the caller of write(), a value of -1 with errno set to the value. Or, alternatively, I should be able to return quetly from the INT 21h with Carry Set and AX = an error code. Any help in this will be greatly appreciated.