Thanks.
I think I've found it in btx.s:
213 mov %eax,%cr0 #
214 ljmp $SEL_SCODE,$init.8 # To 32-bit code
215 .code32
216 init.8: xorl %ecx,%ecx # Zero
And there IS this "ljmp".
Well, this BTX thing is amazing: all this effort, (btxld, run-time
library crt0.o, loader, etc.) seems to just to provide a 32-bit
protected and possibly paging-enabled environment to start the
kernel/loader(and to confuse a new-comer like me.) What are the
other gains? Where can I found more info about this BTX before going
through the ultimate source code? (I've search the mailing-lists.)
Thanks
Weiguang
>From: John Baldwin <[EMAIL PROTECTED]>
>To: Weiguang SHI <[EMAIL PROTECTED]>
>CC: [EMAIL PROTECTED]
>Subject: RE: jmp after setting PE?
>Date: Mon, 23 Jul 2001 12:07:44 -0700 (PDT)
>
>
>On 21-Jul-01 Weiguang SHI wrote:
> > Hi,
> >
> > Please forgive me if this seems too easy.
> >
> > "http://people.freebsd.org/~jhb/386htm/s10_03.htm" says:
> >
> > Immediately after setting the PE flag, the initialization code must
> > flush the processor's instruction prefetch queue by
> > executing a JMP instruction. The 80386 fetches and decodes
> > instructions and addresses before they are used; however,
> > after a change into protected mode, the prefetched instruction
> > information (which pertains to real-address mode) is
> > no longer valid. A JMP forces the processor to discard the invalid
> > information.
> >
> > "/home/src/sys/i386/i386" says:
> >
> > 329 /* Now enable paging */
> > 330 movl R(_IdlePTD), %eax
> > 331 movl %eax,%cr3 /* load ptd addr
> > into mm
> > 332 movl %cr0,%eax /* get control
>word
> > */
> > 333 orl $CR0_PE|CR0_PG,%eax /* enable paging
>*/
> > 334 movl %eax,%cr0 /* and let's
>page
> > NOW! *
> > 335
> > 336 #ifdef BDE_DEBUGGER
> > 337 /*
> > 338 * Complete the adjustments for paging so that we can keep
>tracing
> > throu
> > 339 * initi386() after the low (physical) addresses for the gdt and
>idt
> > bec
> > 340 * invalid.
> > 341 */
> > 342 call bdb_commit_paging
> > 343 #endif
> > 344
> > 345 pushl $begin /* jump to high
> > virtuali
> > 346 ret
>
>We are already in protected mode when the kernel starts (the boot blocks
>call
>us from protected mode) so this isn't turning on the PE bit. Line 333 is
>somewhat misleading (the comment is more accurate) and should probably
>read:
>
> orl $CRO_PG,%eax
>
>If PE isn't on by the time we get here we would have blown up by now
>anyways.
>
>--
>
>John Baldwin <[EMAIL PROTECTED]> -- http://www.FreeBSD.org/~jhb/
>PGP Key: http://www.baldwin.cx/~john/pgpkey.asc
>"Power Users Use the Power to Serve!" - http://www.FreeBSD.org/
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message