[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

[no subject]



Hi ppl. Here is a few paise of muh mind...
> are the four levels in
> >the Intel
> >processors.
>
>     Actually UNIX uses two levels in hardware and
> simulates the other levels
> through software. One reason for not using all the
> four modes is that
> flexibility is lost. I will explain this further:
>     When we talk of levels, we are actually talking
> about the level of
> protection in a particular level. At the highest
> level you have all the
> rights to change any of the CPU registers. At the
> lowest level you have
> rights just enough to perform your work.
>     Here we can implement more levels as done by
> Intel, by gradually
> increasing the protection from the lowest to the
> highest level.
>     This is theoretically a good idea, but when it
> comes to practical
> implementation, this reduces the flexibility. As you
> are aware, the
> superuser (root) has the flexibility of granting a
> particular right to a
> particular (or a group of) users. This would require
> several level changes
> for those users. This further makes the
> implementation of the OS quite
> complicated.

I think U're confused here. The levels here being
referred to are levels of hardware, mainly memory
access and CPU registers. I dont think the super user
and normal user talk comes in here. The 3 levels, that
Khader is talking about are better known in hardware
terms as "rings". On Intel processors, there are 4
rings in which a process in protected mode can run.
ring 0 to ring 3. The kernel, be it doze or Linux, or
any protected mode OS (NOT DOS), runs in ring 0. And
is responsible for assigning virtualized registers for
various other processors. Since the days of the 386,
there is a special mode on the CPU, which is called
the V86 Mode or Virtual 86 mode, which can emulate a
no. of virtual processes, though the control of
execution of the independant processes is given by the
app. running on a higher ring of the protected mode.
Khader, as u are learning about Device Drivers, U must
understand that direct access to memory is NOT allowed
in a protected environment. It was allowed under DOS,
but NEVER under DPMI or VCPI modes, which are the only
way to put the machine into Protected Mode and thereby
allow access to the extended memory, for normal
program relocation. BC 3.1+ provided some functions to
access the mem > 1MB by using EMS or XMS, but the
space could be only used for storage of data, but
NEVER a CS:IP would fall in that area. So,
Technically, u could never overwrite data with u're
code, as the 16 bit regs. of CS and IP didn't allow
for accessing more than that. However, in protected
mode, this is possible, and to prevent other apps,
from writing into u're address space, or storage
location, The Memory Protection offered by The 386+
PM, increases the need for ring based heirarchy in
processors. Since all of the Device memory, be it
Network card buffers, RAM, ROM, Sound Card, Video
cards, etc. ,all of their mem, is mapped on to a
particular loacation in RAM, whose current limit is
4GB. So u have to "REQUEST" the kernel to provide u
access to a specified segment of memory, before
performing I/O ops on it. But, handling PCI devices is
pretty easy, atleast Linux makes it easy.. :) Its got
a cute data structure of pci_dev which can represent
any PCI device, and allows to fiddle with the memory
on the device, w/o bothering about remapping it to
linear address space. See
/usr/src/linux/Documentation/IO-mapping.txt for more
info on IO-remapping on different CPU archs... I think
I've overshooted the topic... I think I'll end it
here... ;-)

>     Regarding the four levels, I think they are just
> named from level 0 to
> level 3 (level 0 being the highest protection).
> Note: I may not be right at this one, others please
> correct ?

ya... ring 0 to ring 3. I dunno if it exists on other
processors. MacOS didn't have multitasking ability,
which NEEDS a mode similar to Intel's V86 mode. So i
doubt if the 68000 had any PM. The PowerPC has it. I
dunno 'bout the Alpha. As far as i know, it must be
having...

Nikhil.
--------------------------------------------------------------------
The Linux India Mailing List Archives are now available.  Please search
the archive at http://lists.linux-india.org/ before posting your question
to avoid repetition and save bandwidth.