i386 start routine

[email protected] (Emmanuel Dreyfus)
Newsgroups gmane.os.netbsd.ports.i386
Message-ID <1oe8gg3.1yqf4yq1d6cqy8M%[email protected]>
Hello

I am playing with multiboot 2 support for our kernel, and I get a crash
involving stuff beyond my x86 knowledge.

The thing happens in the start routine (from
src/sys/arch/i386/i386/locore.S) at the time the kernel has been copied
to high memory and we try to jump there:

        /* 
         * 3. Enable paging and the rest of it.
         */
        movl    %cr0,%eax
        orl     $(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_MP|CR0_WP|CR0_AM),%eax
        movl    %eax,%cr0
         
        pushl   $begin                  /* jump to high mem */
        ret

begin:  

The CR0 change cause the memory pointed by the stack pointer to be
unmapped. As a result, the pushl $begin does not push begin adddress on
the stack, and ret launches us in the twilight zone.

Why enabling protected mode and paging makes a mapping disapear?

-- 
Emmanuel Dreyfus
http://hcpnet.free.fr/pubz
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.