root/arch/i386/stand/boot/srt0.S

/* [<][>][^][v][top][bottom][index][help] */
    1 /*      $OpenBSD: srt0.S,v 1.14 2003/11/22 09:18:25 grange Exp $        */
    2 
    3 /*
    4  * Copyright (c) 1997 Michael Shalayeff
    5  * All rights reserved.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  *
   16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 
   17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
   18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   26  * SUCH DAMAGE.
   27  *
   28  */
   29 #include <machine/asm.h>
   30 #include <assym.h>
   31 
   32 #define BOOTSTACK 0xfffc
   33 
   34         .globl  _C_LABEL(end)
   35         .globl  _C_LABEL(edata)
   36         .globl  _C_LABEL(boot)
   37         .globl  _C_LABEL(_rtt)
   38         .globl  _C_LABEL(bios_bootdev)
   39         .globl  _ASM_LABEL(pmm_init)
   40         .globl  Gdtr
   41 
   42         .text
   43         .code16
   44         .globl  _start
   45 _start:
   46         popl %eax
   47         cmpl $BOOTMAGIC, %eax
   48         je      1f
   49 #ifdef DEBUG
   50         movl    $0xb80a0, %ebx
   51         addr32 movl $0x07420742, (%ebx)
   52 #endif
   53 1:
   54         popl %edx
   55         cli
   56         pushl   %cs
   57         popl    %ds
   58         addr32 data32 lgdt      (Gdtr - LINKADDR)
   59         movl    %cr0, %eax
   60         orl $CR0_PE, %eax
   61         data32 movl %eax, %cr0
   62         data32 ljmp $8, $1f
   63 1:
   64         .code32
   65         movl    $0x10,%eax
   66         mov     %ax,%ds
   67         mov     %ax,%ss
   68         mov     %ax,%es
   69         mov     %ax,%fs
   70         mov     %ax,%gs
   71         movl    $BOOTSTACK,%esp
   72         pushl   %edx
   73         movl    %edx, _C_LABEL(bios_bootdev)
   74 
   75         /* Now do it all */
   76         call    _ASM_LABEL(pmm_init)
   77 #ifdef DEBUG
   78         movl    $0xb80a4, %ebx
   79         movl    $0x07520752, (%ebx)
   80 #endif
   81         /* zero .bss */
   82         xorl    %eax, %eax
   83         movl    $_C_LABEL(end), %ecx
   84         subl    $_C_LABEL(edata),%ecx
   85         movl    $_C_LABEL(edata), %edi
   86         cld
   87         rep;    stosb
   88 
   89         call    _C_LABEL(boot)
   90 
   91         jmp     _C_LABEL(_rtt)
   92 

/* [<][>][^][v][top][bottom][index][help] */