Subject: | |
From: | |
Reply To: | |
Date: | Sat, 6 Sep 1997 11:00:29 PST |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
Gavin after me after Stan after me (starting to sound like a rap song):
>>> GETPRIVMODE (); /* unless caller was already in priv mode */
>>>
>>>> return get_control_reg(10) & 0xff;
>>
>>Stan is, of course, correct about the need for GETPRIVMODE () if these
>>routines don't exist already exist in a privileged XL.
>Control registers (other than SAR, CR26, CR27, and the Interval Timer if
>the S bit in the PWS is off) can only be read at the "most privileged
>level", i.e. ring zero, so the GETPRIVMODE() call here isn't going to
>do you any good, as get_control_reg is not a not a function but a
>compiler construct that expands inline to an MFCTL instruction which
>will trap due to the code not executing at a sufficient privilege level
>(GETPRIVMODE() promotes a process from ring 3 to ring 2).
Actually, notice the language - it is C and I can personally attest that it
doesn't expand internally to a mfctl! :-)
Using AVATAR from Lund (written by Stan and one of the most useful tools
around), we see that:
AVATAR: open nl.pub.sys
Assuming space $A for NL.PUB.SYS
----> LST Module Directory <---- Starts @ #Length
1 HP31900 $0012e000 21143704
... [snip]
Select a module number > 1
Module # 1: HP31900
Found 17051 unwind entries.
Searching 91598 symbol dictionary entries
Sorting 57379 symbols
FILE TYPE : sharable, executable SOM
AVATAR[nl.pub.sys]: look get_control_reg
symbol name : get_control_reg
address : fcaab8
symbol_type : unspecified code
symbol_scope : exported symbol for other SOMs
check_level : 0
must_qualify : 0
initially_frozen : 0
memory_resident : 1
is_common : 0
duplicate_common : 0
xleast : 2
privilege level : 0
code offset : 185a98 - 185bb4 (72 instructions)
AVATAR[nl.pub.sys]:
For those unfamiliar with AVATAR, I'll explain the above output. We see
that get_control_reg is in fact a procedure in the NL. Its xleast is 2
indicating that it must be called at ring 2, and its privilege level is 0
indicating that it runs at ring 0. Hence, we need to be in privileged mode
(GETPRIVMODE() switches to ring 2 given correct permissions) to call it,
and since it runs at ring 0, all control registers can be returned by it.
>Nyeah. :-)
Same to ya! ;-) (We're starting to sound like my kids)
|
|
|