Subj : Writing Devicedriver (Using EMX C++)
To : Jonathan de Boyne Pollard
From : Daniela Engert
Date : Wed Nov 10 2004 04:12 am
Hi Jonathan!
Thus quoth Jonathan de Boyne Pollard to David Noon:
DN>>> I doubt if OS/2 would load a PDD with 32-bit code in it.
The kernel *forces* all segments in a PDD to 16-bit on load, ignoring the
32-bit-indicator in the file image. I learned this from my own experiments on
this subject.
DT>>> OS/2 will load a PDD with 32 bit code segments just fine.
Dennis, this is true - but see above.
DT>>> The "interface" to the rest of the system is still via 16 bit
DT>>> addressing. The PDD needs to be able to be called via a 16 bit
DT>>> interface and use 16 bit DevHelp. Just some "assembly glue"
DT>>> required. <g>
Exactly, very easy indeed!
JdBP> As far as I know, the restriction on I/O instructions applies to
JdBP> application programs running in user mode, not physical device
JdBP> drivers running in kernel mode. So both 16-bit and 32-bit code
JdBP> can perform I/O instructions just fine in a PDD. (This is to be
JdBP> expected, anyway, since PDDs run at ring 0, and the x86
JdBP> architecture doesn't allow IOPL to be set lower than 0!)
This is true, tested by myself.
JdBP> The questions that are raised, however, are:
JdBP> What are the base and limit of the 32-bit selectors in CS/DS/SS
JdBP> for a 32-bit PDD ? Are they based at the same address as the
JdBP> user-mode flat-model CS/DS/SS selectors ?
No.
JdBP> I assume that they are GDT selectors.
Of course, since driver segments must be addressable in every processor
context.
JdBP> But who creates the GDT entries ? Does the PDD loader do it,
JdBP> and provide a kernel-mode thunking mechanism that all PDDs can
JdBP> use ?
No, up to now, the kernel has no 32-bit PDD support (see above also). If you
like to have a 32-bit PDD, you have to construct it yourself *after load time*.
So your driver itself switches from a 'mini 16-bit PDD' to a full fledged
32-bit PDD by modifying its code segment descriptor in the GDT at any point at
init time. The thunking is no problem at all, just 4 instructions in case of
the DevHlp calls.
JdBP> If so, what is it ? Or is each 32-bit PDD expected to create its
JdBP> own private selectors ?
JdBP> Anyone know ?