Annotation of Net2/arch/i386/stand/srt0.c, revision 1.1.1.4

1.1       root        1: /*-
                      2:  * Copyright (c) 1990 The Regents of the University of California.
                      3:  * All rights reserved.
                      4:  *
                      5:  * This code is derived from software contributed to Berkeley by
                      6:  * William Jolitz.
                      7:  *
                      8:  * Redistribution and use in source and binary forms, with or without
                      9:  * modification, are permitted provided that the following conditions
                     10:  * are met:
                     11:  * 1. Redistributions of source code must retain the above copyright
                     12:  *    notice, this list of conditions and the following disclaimer.
                     13:  * 2. Redistributions in binary form must reproduce the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer in the
                     15:  *    documentation and/or other materials provided with the distribution.
                     16:  * 3. All advertising materials mentioning features or use of this software
                     17:  *    must display the following acknowledgement:
                     18:  *     This product includes software developed by the University of
                     19:  *     California, Berkeley and its contributors.
                     20:  * 4. Neither the name of the University nor the names of its contributors
                     21:  *    may be used to endorse or promote products derived from this software
                     22:  *    without specific prior written permission.
                     23:  *
                     24:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     25:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     26:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     27:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     28:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     29:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     30:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     31:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     32:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     33:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     34:  * SUCH DAMAGE.
                     35:  *
1.1.1.4 ! root       36:  *     from: @(#)srt0.c        5.3 (Berkeley) 4/28/91
        !            37:  *     srt0.c,v 1.2 1993/05/22 08:02:23 cgd Exp
1.1       root       38:  */
                     39: 
                     40: /*
                     41:  * Startup code for standalone system
                     42:  * Non-relocating version -- for programs which are loaded by boot
                     43:  * Relocating version for boot
                     44:  * Small relocating version for "micro" boot
                     45:  */
                     46: 
                     47:        .globl  _end
                     48:        .globl  _edata
                     49:        .globl  _main
                     50:        .globl  __rtt
                     51:        .globl  _exit
                     52:        .globl  _bootdev
                     53:        .globl  _cyloffset
1.1.1.3   root       54: #define        NOP     inb $0x84,%al ; inb $0x84,%al
1.1       root       55: 
                     56: #ifdef SMALL
                     57:        /* where the disklabel goes if we have one */
                     58:        .globl  _disklabel
                     59: _disklabel:
                     60:        .space 512
1.1.1.3   root       61:        .globl _scsisn
                     62:        .set _scsisn, RELOC+0x60
1.1       root       63: #endif
                     64: 
1.1.1.2   root       65:        .globl  entry
                     66:        .set entry,0
1.1       root       67:        .globl  start
                     68: 
                     69: #if    defined(REL) && !defined(SMALL)
                     70: 
                     71:        /* relocate program and enter at symbol "start" */
                     72: 
                     73:        #movl   $entry-RELOC,%esi       # from beginning of ram
                     74:        movl    $0,%esi
                     75:        #movl   $entry,%edi             # to relocated area
                     76:        movl    $ RELOC,%edi            # to relocated area
                     77:        # movl  $_edata-RELOC,%ecx      # this much
                     78:        movl    $64*1024,%ecx
                     79:        cld
                     80:        rep
                     81:        movsb
                     82:        # relocate program counter to relocation base
                     83:        pushl   $start
                     84:        ret
                     85: #endif
                     86: 
                     87: start:
                     88: 
                     89:        /* setup stack pointer */
                     90: 
                     91: #ifdef REL
                     92:        leal    4(%esp),%eax    /* ignore old pc */
1.1.1.3   root       93:        movl    $ RELOC-3*4,%ebx
                     94:        /* copy boot parameters */
1.1       root       95:        pushl   $3*4
                     96:        pushl   %ebx
                     97:        pushl   %eax
                     98:        call    _bcopy
                     99:        movl    %ebx,%esp
                    100: #else
                    101:        /* save old stack state */
                    102:        movl    %esp,savearea
                    103:        movl    %ebp,savearea+4
                    104:        movl    $ RELOC-0x2400,%esp
                    105: #endif
                    106: 
                    107:        /* clear memory as needed */
                    108: 
                    109:        movl    %esp,%esi
                    110: #ifdef REL
                    111: 
                    112:        /*
                    113:         * Clear Bss and up to 64K heap
                    114:         */
                    115:        movl    $64*1024,%ebx
                    116:        movl    $_end,%eax      # should be movl $_end-_edata but ...
                    117:        subl    $_edata,%eax
1.1.1.3   root      118:        #addl   %ebx,%eax
1.1       root      119:        pushl   %eax
                    120:        pushl   $_edata
                    121:        call    _bzero
                    122: 
                    123:        /*
                    124:         * Clear 64K of stack
                    125:         */
                    126:        movl    %esi,%eax
                    127:        subl    %ebx,%eax
                    128:        subl    $5*4,%ebx
                    129:        pushl   %ebx
                    130:        pushl   %eax
                    131:        call    _bzero
                    132: #else
                    133:        movl    $_edata,%edx
                    134:        movl    %esp,%eax
                    135:        subl    %edx,%eax
                    136:        pushl   %edx
                    137:        pushl   %esp
                    138:        call    _bzero
                    139: #endif
                    140: 
                    141:        call    _kbdreset       /* resets keyboard and gatea20 brain damage */
1.1.1.3   root      142:        movl    %esi,%esp
1.1       root      143:        call    _main
                    144:        jmp     1f
                    145: 
                    146:        .data
                    147: _bootdev:      .long   0
                    148: _cyloffset:    .long   0
                    149: savearea:      .long   0,0     # sp & bp to return to
                    150:        .text
                    151:        .globl _wait
                    152: 
                    153: __rtt:
                    154:        pushl   $1000000
                    155:        call    _wait
                    156:        popl    %eax
                    157:        movl    $-7,%eax
                    158:        jmp     1f
1.1.1.2   root      159: 
1.1       root      160: _exit:
1.1.1.2   root      161:        pushl   $1000000
                    162:        call    _wait
                    163:        popl    %eax
1.1       root      164:        movl    4(%esp),%eax
                    165: 1:
                    166: #ifdef REL
                    167: #ifndef SMALL
                    168:        call    _reset_cpu
                    169: #endif
                    170:        movw    $0x1234,%ax
                    171:        movw    %ax,0x472       # warm boot
                    172:        movl    $0,%esp         # segment violation
                    173:        ret
                    174: #else
                    175:        movl    savearea,%esp
                    176:        movl    savearea+4,%ebp
                    177:        ret
                    178: #endif
                    179: 
                    180:        .globl  _inb
                    181: _inb:  movl    4(%esp),%edx
                    182:        subl    %eax,%eax       # clr eax
1.1.1.3   root      183:        NOP
1.1       root      184:        inb     %dx,%al
                    185:        ret
                    186: 
                    187:        .globl  _outb
                    188: _outb: movl    4(%esp),%edx
1.1.1.3   root      189:        NOP
1.1       root      190:        movl    8(%esp),%eax
                    191:        outb    %al,%dx
                    192:        ret
                    193: 
                    194:        .globl ___udivsi3
                    195: ___udivsi3:
                    196:        movl 4(%esp),%eax
                    197:        xorl %edx,%edx
                    198:        divl 8(%esp)
                    199:        ret
                    200: 
                    201:        .globl ___divsi3
                    202: ___divsi3:
                    203:        movl 4(%esp),%eax
                    204:        xorl %edx,%edx
                    205:        cltd
                    206:        idivl 8(%esp)
                    207:        ret
                    208: 
                    209:        #
                    210:        # bzero (base,cnt)
                    211:        #
                    212: 
                    213:        .globl _bzero
                    214: _bzero:
                    215:        pushl   %edi
                    216:        movl    8(%esp),%edi
                    217:        movl    12(%esp),%ecx
                    218:        movb    $0x00,%al
                    219:        cld
                    220:        rep
                    221:        stosb
                    222:        popl    %edi
                    223:        ret
                    224: 
                    225:        #
                    226:        # bcopy (src,dst,cnt)
                    227:        # NOTE: does not (yet) handle overlapped copies
                    228:        #
                    229: 
                    230:        .globl  _bcopy
                    231: _bcopy:
                    232:        pushl   %esi
                    233:        pushl   %edi
                    234:        movl    12(%esp),%esi
                    235:        movl    16(%esp),%edi
                    236:        movl    20(%esp),%ecx
                    237:        cld
                    238:        rep
                    239:        movsb
                    240:        popl    %edi
                    241:        popl    %esi
                    242:        ret
                    243: 
                    244:        # insw(port,addr,cnt)
                    245:        .globl  _insw
                    246: _insw:
                    247:        pushl   %edi
                    248:        movw    8(%esp),%dx
                    249:        movl    12(%esp),%edi
                    250:        movl    16(%esp),%ecx
1.1.1.3   root      251:        NOP
1.1       root      252:        cld
                    253:        nop
                    254:        .byte 0x66,0xf2,0x6d    # rep insw
                    255:        nop
                    256:        movl    %edi,%eax
                    257:        popl    %edi
                    258:        ret
                    259: 
                    260:        # outsw(port,addr,cnt)
                    261:        .globl  _outsw
                    262: _outsw:
                    263:        pushl   %esi
                    264:        movw    8(%esp),%dx
                    265:        movl    12(%esp),%esi
                    266:        movl    16(%esp),%ecx
1.1.1.3   root      267:        NOP
1.1       root      268:        cld
                    269:        nop
                    270:        .byte 0x66,0xf2,0x6f    # rep outsw
                    271:        nop
                    272:        movl    %esi,%eax
                    273:        popl    %esi
                    274:        ret

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.