From owner-freebsd-hackers Tue Nov 17 03:27:38 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id DAA26174 for freebsd-hackers-outgoing; Tue, 17 Nov 1998 03:27:38 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from ceia.nordier.com (m2-59-dbn.dial-up.net [196.34.155.123]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id DAA26152 for ; Tue, 17 Nov 1998 03:27:05 -0800 (PST) (envelope-from rnordier@nordier.com) Received: (from rnordier@localhost) by ceia.nordier.com (8.8.7/8.6.12) id NAA09173; Tue, 17 Nov 1998 13:11:58 +0200 (SAT) From: Robert Nordier Message-Id: <199811171111.NAA09173@ceia.nordier.com> Subject: Re: FreeBSD on i386 memory model In-Reply-To: <3.0.5.32.19981117103136.009058a0@mail.scancall.no> from Marius Bendiksen at "Nov 17, 98 10:31:36 am" To: Marius.Bendiksen@scancall.no (Marius Bendiksen) Date: Tue, 17 Nov 1998 13:11:54 +0200 (SAT) Cc: ru@ucb.crimea.ua, mike@smith.net.au, rnordier@nordier.com, hackers@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL31 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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