From owner-freebsd-hackers Fri Jun 14 2:46:48 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from anchor-post-30.mail.demon.net (anchor-post-30.mail.demon.net [194.217.242.88]) by hub.freebsd.org (Postfix) with ESMTP id 3FD5D37B445 for ; Fri, 14 Jun 2002 02:46:26 -0700 (PDT) Received: from pr-webmail-1.demon.net ([194.159.244.51] helo=web.mail.demon.net) by anchor-post-30.mail.demon.net with smtp (Exim 3.35 #1) id 17Inex-0008gZ-0U; Fri, 14 Jun 2002 10:46:23 +0100 Received: from ubik.demon.co.uk ([194.70.246.1]) by web.mail.demon.net with http; Fri, 14 Jun 2002 10:46:23 +0100 From: tony@ubik.demon.co.uk To: "Sergey Lyubka" , hackers@freebsd.org In-Reply-To: <20020614115010.B20213@oasis.uptsoft.com> Subject: Re: locore.s quiestion Date: Fri, 14 Jun 2002 10:46:23 +0100 User-Agent: Demon-WebMail/2.0 MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG devnull@uptsoft.com wrote: > Hello, Hi > I am writing an article about FreeBSD's startup > and kernel init > (it is at http://oasis.uptsoft.com/~devnull/dh/boot.html > for whom it may be interesting) I get a "no route to host" error. > I am stucked at two lines in locore.s (IA 32 arch) > > /usr/src/sys/i386/i386/locore.s: > > pushl $begin /* jump to high virtualized address */ > ret > > /* now running relocated at KERNBASE where the system is linked to run */ > begin: > /* set up bootstrap stack */ > > My question is: > why this is done. My understanding was that the loader > loaded the kernel at high virtual address already, > so there's no need to jump. It does exactly what it says on the tin. (To quote a long running UK tv advert series.) This code runs in real mode. The code prior to this detects the cpu type, etc... then sets up the virtual/paged memory mapping tables, then immediately prior to the code you quote is this bit: /* Now enable paging */ movl R(IdlePTD), %eax movl %eax,%cr3 /* load ptd addr into mmu */ movl %cr0,%eax /* get control word */ orl $CR0_PE|CR0_PG,%eax /* enable paging */ movl %eax,%cr0 /* and let's page NOW! */ Which enables paged memory mode in the processor control register. However to actually start using paged memory Intel's CPU documentation requires a flush and reload of the instruction stream. The pushl & ret are a convenient way to do this, possibly recommended by Intel - I don't have the relevant documentation to hand. The result is that the instruction after 'begin:' is the first to be executed in paged mode. Cheers, Tony To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message