Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Nov 1998 13:11:54 +0200 (SAT)
From:      Robert Nordier <rnordier@nordier.com>
To:        Marius.Bendiksen@scancall.no (Marius Bendiksen)
Cc:        ru@ucb.crimea.ua, mike@smith.net.au, rnordier@nordier.com, hackers@FreeBSD.ORG
Subject:   Re: FreeBSD on i386 memory model
Message-ID:  <199811171111.NAA09173@ceia.nordier.com>
In-Reply-To: <3.0.5.32.19981117103136.009058a0@mail.scancall.no> from Marius Bendiksen at "Nov 17, 98 10:31:36 am"

next in thread | previous in thread | raw e-mail | index | archive | help
Marius Bendiksen wrote:

> >Could you please explain why it is _faster_ than ``lcall' and what is
> >the difference between them?
> 
> This has to do with call gates vs interrupts.
> 
> >The only difference that I know of at the moment is that ``int 0x80''
> >will push EFlags, CS:EIP into stack, while ``lcall'' will only push
> >CS:EIP pair.
> 
> Not quite true always. An lcall directly into a code segment which you have
> proper rights for, will do that. An lcall to a call gate may do quite a
> number of such operations, and- in the case of task gates- may cause a
> complete task switch. Similarly, there are multiple kinds of interrupts-
> trap interrupts, 'true' interrupts and task interrupts.

As Marius says, it's mainly down to what the instructions point at,
rather that the instructions themselves.  Though, that said, an
interrupt rather than a far call is also just a more "natural" way to
accomplish the particular task.  (Anyway, go see for yourself: the
relevant functions are in src/sys/i386/i386/exception.s.)

> 
> Refer to the Intel 80386 technical docs, available from developer.intel.com
> 
> >Where is the code that sets up protected mode and defines the layout
> >of the kernel?
> 
> I believe this is in the second or third stage boot loader, but I may be
> mistaken, as I've never had a look at it. The first stage boot loader is
> too small to do such a thing, unless you use hardcoded offsets for the
> entrypoints and system structures. Doing it in the actual kernel seems
> stupid, as that would leave code in the kernel which is useless after bootup.

In fact, almost all initialization is done in the kernel.  Some basic
(unavoidable) initialization takes place in the bootstrap (on the i386,
getting into protected mode, enabling the A20 line, etc) but as little
as possible.

There has been some discussion about moving more of the initialization
into the bootstrap code, but I won't really agree that doing it in the
kernel is "stupid".  Just as writing almost everything in C (rather
than assembler) is part of the UNIX philosophy, convenience and
maintainability are often more important than merely saving bytes.

If you're interested in this stuff, you probably want to look at many
of the files in src/sys/i386/i386, starting with locore.s (where the
actual interaction with the bootstrap takes place).

-- 
Robert Nordier

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199811171111.NAA09173>