cale@lut.fi (Antti Kirmanen) (04/09/91)
I'm currently trying to write a device driver for OS/2. My problem is, that I should use inp and outp functions to communicate with a port. OS/2 programmers reference manual says, that I should use DosPortAccess() function call but then ... Program crashes allways in the first outp() or inp() call. I'm using Microsoft C 6.0 with OS/2 1.1 Can anyone help me. A simple example would be great. Thanks in advance.... Please e-mail: cale@kannel.lut.fi -- __________________________________________________ : Antti Kirmanen internet: cale@kannel.lut.fi : : Laserkatu 2 E 7 53850 LPR tel 953-20079 : --------------------------------------------------
winter@hpmcaa.mcm.hp.com (Kirt Alan Winter) (04/11/91)
cale@lut.fi (Antti Kirmanen) writes: > > I'm currently trying to write a device driver for OS/2. > My problem is, that I should use inp and outp functions to > communicate with a port. OS/2 programmers reference manual > says, that I should use DosPortAccess() function call but then ... > Program crashes allways in the first outp() or inp() call. > I'm using Microsoft C 6.0 with OS/2 1.1 > > Can anyone help me. A simple example would be great. > Thanks in advance.... Well, I just faced the same problem (though not inside a device driver), so I can perhaps shed a little light on the problem. The routines that do port I/O must execute at the IOPL (sorry if my OS/2 terminology is a bit sloppy, I'm new at this). Near as I can tell, it is useless to put the outp and inp calls in the library, as they will not work. I ended up writing my own inp and outp in assembly, so I could declare them as IOPL in the module definition file. For a better explanation, refer to Ray Duncan's _Advanced OS/2 Programming_, chapter 14. Kirt ------------------------------------------------------------------------------ Kirt Alan Winter winter@hpmcaa.mcm.hp.com Hewlett Packard - Cardiology Business Unit (503) 472-5101 x371 McMinnville, Oregon ------------------------------------------------------------------------------
ford@hpmcaa.mcm.hp.com (Dan Ford) (04/11/91)
Also be sure that you have IOPL=YES in your config.sys. The code segment containing the INP or OUTP must be named in the .DEF file with the IOPL attribute, for example : . SEGMENTS IO_TEXT IOPL : . Good luck, Dan
d88-pfo@dront.nada.kth.se (Peter Forsberg) (04/12/91)
In article <1991Apr10.211127.13982@hpmcaa.mcm.hp.com> winter@hpmcaa.mcm.hp.com (Kirt Alan Winter) writes: cale@lut.fi (Antti Kirmanen) writes: > > I'm currently trying to write a device driver for OS/2. > My problem is, that I should use inp and outp functions to > communicate with a port. OS/2 programmers reference manual > says, that I should use DosPortAccess() function call but then ... > Program crashes allways in the first outp() or inp() call. > I'm using Microsoft C 6.0 with OS/2 1.1 > > Can anyone help me. A simple example would be great. > Thanks in advance.... The reason that you should use the DosPortAccess() API is *portability*. In OS/2 2.0 32-bit programs neither IOPL-segments, nor the C-functions inp() or outp() will be supported. This is because this is very hardware- specific stuff, and will be hard to support in (possible) future versions of OS/2 on hardware platforms other than the i[34]86 ("New Technology"). Just for your info... / Peter Forsberg (RIT & IBM Sweden) -- _______________________________________________________________________________ Peter Forsberg Royal Institute of Technology, Stockholm, Sweden. Internet: d88-pfo@nada.kth.se ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
klos@bcrvmpc3.vnet.ibm.com (Marty Klos) (04/12/91)
References: <1991Apr09.151935.19325@lut.fi> I know that in IBM C/2 (MSC 5.1), the i/o routines were already in a separate segment in the large model libraries. You could access them by using a .def file to the linker containing the line: SEGMENTS '_IOSEG' CLASS 'IOSEG_CODE' IOPL Although I haven't used MSC 6.0, I would suspect it still works. Try looking in the .map file for your program that uses inp or outp. If you see 'IOSEG_CODE', then this should work. Beware, there is a performance hit (vs DOS) because every call to an IOPL routine from a non-IOPL routine goes through a call gate. Also, be aware that you will need the function versions of inp and outp, not the *intrinsic* (translation: in-line) versions. Marty Klos/Internet: klos@vnet.ibm.com
janm@dramba.neis.oz (Jan Mikkelsen) (04/13/91)
In article <1991Apr09.151935.19325@lut.fi> cale@lut.fi (Antti Kirmanen) writes: > >I'm currently trying to write a device driver for OS/2. >My problem is, that I should use inp and outp functions to >communicate with a port. OS/2 programmers reference manual >says, that I should use DosPortAccess() function call but then ... >Program crashes allways in the first outp() or inp() call. >I'm using Microsoft C 6.0 with OS/2 1.1 > You need to do a "#pragma intrinsic" for inp() and outp() in your source code. It has been some time since I did a device driver for OS/2, but I believe this will solve your problem. -- Jan Mikkelsen janm@dramba.neis.oz.AU or janm%dramba.neis.oz@metro.ucc.su.oz.au "She really is."
jmorris@imagine.matrox.com (Jacques Morris) (06/12/91)
I'm writing an interrupt-driven device driver for OS/2 and have been stumped by a bug for a while. I'm running OS/2 on a ALR 80386 EISA machine and I've reserved interrupt level 7 for my device. I'm using the Microsoft DDK with the debugger kernel os2krnl.170. After installing this driver at boot time (without errors) I issue a DosDevIOCtl() call with the device function parameter set to 0x80. At this point the CPU (80386) generates an exception and the debugger issues the message Trap 8 - Double Exception Detected 0000 AX=0067 BX=E000 CX=03FF DX=0131 SP=007C BP=626F SI=014C DI=0000 IP=36C9 CS=0230 DS=0B58 ES=01A8 SS=1970 -- NV UP DI NG NZ NA PO CY GDTR=110020 1B5F IDTR=11336E 03FF TR=0010 LDTR=0028 IOPL=1 MSW=PM EM TS 0230:36C9 1E PUSH DS ...processing then continues until a second exception occurs... Trap 12 (0CH) - Stack Segment Overrun or Not Present 0000 AX=3848 BX=E024 CX=FFFE DX=002C SP=004E BP=0076 SI=1604 DI=002D IP=002B CS=01F0 DS=01F8 ES=01F8 SS=1970 -- NV UP DI NG NZ NA PO CY GDTR=110020 1B5F IDTR=11336E 03FF TR=0010 LDTR=0028 IOPL=3 MSW=PM EM TS 01F0:002B 36F6063EFF01 TEST BYTE PTR SS:[FF3E],01 SS:FF3E=INVALID Continuing the processing at this point hangs the system and the kernel issues the following message before dying: The system detected an internal processing error at location # 0230:0008 Now these exceptions seem to occur in the kernel so debugging is difficult to say the least. If anyone has any ideas please let me know by E-Mail. I would greatly appreciate it! Thanks. ______________________________________________________________________ Jacques Morris E-Mail : jmorris@matrox.com Software engineer Voice : (514) 685-7230 ext. 2319 Matrox Electronics Systems Fax : (514) 685-2853 Montreal, Canada Date : June 11th, 1991 ______________________________________________________________________ The opinions expressed are not mine. I found them somewhere, I swear. ______________________________________________________________________