[BACK]Return to bootxx.S CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / arch / i386 / stand / bootxx

Annotation of src/sys/arch/i386/stand/bootxx/bootxx.S, Revision 1.10.60.1

1.10.60.1! martin      1: /*     $NetBSD$        */
1.1       dsl         2:
                      3: /*-
                      4:  * Copyright (c) 2003 The NetBSD Foundation, Inc.
                      5:  * All rights reserved.
                      6:  *
                      7:  * This code is derived from software contributed to The NetBSD Foundation
                      8:  * by David Laight.
                      9:  *
                     10:  * Redistribution and use in source and binary forms, with or without
                     11:  * modification, are permitted provided that the following conditions
                     12:  * are met:
                     13:  * 1. Redistributions of source code must retain the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer.
                     15:  * 2. Redistributions in binary form must reproduce the above copyright
                     16:  *    notice, this list of conditions and the following disclaimer in the
                     17:  *    documentation and/or other materials provided with the distribution.
                     18:  *
                     19:  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
                     20:  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
                     21:  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
                     22:  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
                     23:  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
                     24:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
                     25:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
                     26:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
                     27:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
                     28:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
                     29:  * POSSIBILITY OF SUCH DAMAGE.
                     30:  */
                     31:
                     32: #include <machine/asm.h>
1.2       lukem      33: #include <sys/bootblock.h>
1.1       dsl        34:
                     35: /*
                     36:  * Code linked to 0xa00 and copied to sectors 2+ of the netbsd boot
                     37:  * partition by MI /usr/sbin/installboot.
                     38:  * Read into memory by code in pbr.S
                     39:  *
                     40:  * On entry:
                     41:  *     %dl                     BIOS drive number
1.10      jakllsch   42:  *     %edi:%esi               Sector number of NetBSD partition
1.1       dsl        43:  *     %cs, %ds, %es, %ss      All zero
                     44:  *     %sp                     near 0xfffc
                     45:  */
                     46:        .text
                     47:        .code16
                     48: ENTRY(bootxx)
                     49:        jmp     1f
1.3       dsl        50:        .balign 4
1.1       dsl        51: ENTRY(bootxx_magic)
                     52:        .long   X86_BOOT_MAGIC_1        /* checked by installboot & pbr code */
1.6       junyoung   53: boot_params:                           /* space for patchable variables */
                     54:        .long   1f - boot_params        /* length of this data area */
1.3       dsl        55: #include <boot_params.S>
1.7       dsl        56:        . = bootxx + 0x80               /* Space for patching unknown params */
1.1       dsl        57:
                     58: 1:     call    gdt_fixup
                     59:
                     60:        calll   real_to_prot
                     61:        .code32
                     62:
1.10      jakllsch   63:        push    %edi
1.1       dsl        64:        movl    $_end, %ecx             /* zero bss */
                     65:        movl    $__bss_start, %edi
                     66:        subl    %edi, %ecx
                     67:        shr     $2, %ecx                /* _end and __bss_start are aligned */
                     68:        xor     %eax, %eax
                     69:        rep
                     70:        stosl
1.10      jakllsch   71:        pop     %edi
1.1       dsl        72:
1.10      jakllsch   73:        movzbl  %dl, %edx
                     74:        push    %edi                    /* save args for secondary bootstrap */
                     75:        push    %esi
1.5       dsl        76:        movl    %esp, %esi              /* address of sector number */
1.1       dsl        77:        push    %edx
                     78:        push    %esi                    /* args for boot1 */
                     79:        push    %edx
                     80:        call    _C_LABEL(boot1)         /* C code to load /boot */
                     81:        add     $8, %esp
                     82:        call    prot_to_real
                     83:        .code16
                     84:
                     85:        test    %ax, %ax
                     86:        jnz     boot_fail
                     87:
                     88:        pop     %edx                    /* bios disk number */
                     89:        pop     %ebx                    /* expected partition start sector */
1.10      jakllsch   90:        pop     %ecx
1.6       junyoung   91:        movl    $boot_params, %esi
1.10      jakllsch   92:        orb     $X86_BP_FLAGS_LBA64VALID, 4(%esi)
1.1       dsl        93:        lcall   $SECONDARY_LOAD_ADDRESS/16, $0
                     94:
                     95: boot_fail:
1.4       dsl        96:        push    %ax                     /* error string from boot1 */
                     97:        movw    errno, %ax
                     98:        aam                             /* largest errno is < 100 */
                     99:        addw    $('0' << 8) | '0', %ax  /* to ascii */
                    100:        rorw    $8, %ax
1.10.60.1! martin    101:        cmpb    $'0', %al               /* suppress leading zero */
1.4       dsl       102:        jne     10f
                    103:        movb    $' ', %al
                    104: 10:    movw    %ax, 12f
                    105:        movw    $11f, %si
                    106:        call    message                 /* output boot failed message */
1.1       dsl       107:        pop     %si
1.4       dsl       108:        call    message                 /* and text from boot1 */
1.1       dsl       109:        jmp     loopstop
1.4       dsl       110: 11:    .ascii  "Boot failed (errno "
                    111: 12:    .asciz  "xx): "
1.1       dsl       112:
                    113: ENTRY(_rtt)
                    114:        .code32
                    115:        call    prot_to_real
                    116:        .code16
                    117: loopstop:
                    118:        movb    0x86, %ah               /* delay for about a second */
                    119:        movw    $16, %cx
                    120:        int     $0x15
                    121:        int     $0x18                   /* might be a boot fail entry */
1.4       dsl       122: 1:     sti                             /* if not loopstop */
1.1       dsl       123:        hlt
                    124:        jmp     1b
                    125:
                    126:        /*
                    127:         * Vector the fs calls through here so we can support multiple
                    128:         * file system types with one copy of the library code and
                    129:         * multiple copies of this file.
                    130:         */
                    131:        .global xxfs_open, xxfs_close, xxfs_read, xxfs_stat
                    132:        .code32
                    133: xxfs_open:     jmp     XXfs_open
                    134: xxfs_close:    jmp     XXfs_close
                    135: xxfs_read:     jmp     XXfs_read
                    136: xxfs_stat:     jmp     XXfs_stat

CVSweb <webmaster@jp.NetBSD.org>