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

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:  *
                     36:  *     @(#)srt0.c      5.3 (Berkeley) 4/28/91
                     37:  */
                     38: 
                     39: /*
                     40:  * Startup code for standalone system
                     41:  * Non-relocating version -- for programs which are loaded by boot
                     42:  * Relocating version for boot
                     43:  * Small relocating version for "micro" boot
                     44:  */
                     45: 
                     46:        .globl  _end
                     47:        .globl  _edata
                     48:        .globl  _main
                     49:        .globl  __rtt
                     50:        .globl  _exit
                     51:        .globl  _bootdev
                     52:        .globl  _cyloffset
                     53: 
                     54: #ifdef SMALL
                     55:        /* where the disklabel goes if we have one */
                     56:        .globl  _disklabel
                     57: _disklabel:
                     58:        .space 512
                     59: #endif
                     60: 
1.1.1.2 ! root       61:        .globl  entry
        !            62:        .set entry,0
1.1       root       63:        .globl  start
                     64: 
                     65: #if    defined(REL) && !defined(SMALL)
                     66: 
                     67:        /* relocate program and enter at symbol "start" */
                     68: 
                     69:        #movl   $entry-RELOC,%esi       # from beginning of ram
                     70:        movl    $0,%esi
                     71:        #movl   $entry,%edi             # to relocated area
                     72:        movl    $ RELOC,%edi            # to relocated area
                     73:        # movl  $_edata-RELOC,%ecx      # this much
                     74:        movl    $64*1024,%ecx
                     75:        cld
                     76:        rep
                     77:        movsb
                     78:        # relocate program counter to relocation base
                     79:        pushl   $start
                     80:        ret
                     81: #endif
                     82: 
                     83: start:
                     84: 
                     85:        /* setup stack pointer */
                     86: 
                     87: #ifdef REL
                     88:        leal    4(%esp),%eax    /* ignore old pc */
                     89:        movl    $ RELOC-4*4,%esp
                     90:        /* copy down boot parameters */
                     91:        movl    %esp,%ebx
                     92:        pushl   $3*4
                     93:        pushl   %ebx
                     94:        pushl   %eax
                     95:        call    _bcopy
                     96:        movl    %ebx,%esp
                     97: #else
                     98:        /* save old stack state */
                     99:        movl    %esp,savearea
                    100:        movl    %ebp,savearea+4
                    101:        movl    $ RELOC-0x2400,%esp
                    102: #endif
                    103: 
                    104:        /* clear memory as needed */
                    105: 
                    106:        movl    %esp,%esi
                    107: #ifdef REL
                    108: 
                    109:        /*
                    110:         * Clear Bss and up to 64K heap
                    111:         */
                    112:        movl    $64*1024,%ebx
                    113:        movl    $_end,%eax      # should be movl $_end-_edata but ...
                    114:        subl    $_edata,%eax
                    115:        addl    %ebx,%eax
                    116:        pushl   %eax
                    117:        pushl   $_edata
                    118:        call    _bzero
                    119: 
                    120:        /*
                    121:         * Clear 64K of stack
                    122:         */
                    123:        movl    %esi,%eax
                    124:        subl    %ebx,%eax
                    125:        subl    $5*4,%ebx
                    126:        pushl   %ebx
                    127:        pushl   %eax
                    128:        call    _bzero
                    129: #else
                    130:        movl    $_edata,%edx
                    131:        movl    %esp,%eax
                    132:        subl    %edx,%eax
                    133:        pushl   %edx
                    134:        pushl   %esp
                    135:        call    _bzero
                    136: #endif
1.1.1.2 ! root      137:        /*movl  %esi,%esp*/
1.1       root      138: 
1.1.1.2 ! root      139:        /*pushl $0
        !           140:        popf*/
1.1       root      141: 
                    142:        call    _kbdreset       /* resets keyboard and gatea20 brain damage */
                    143: 
                    144:        call    _main
                    145:        jmp     1f
                    146: 
                    147:        .data
                    148: _bootdev:      .long   0
                    149: _cyloffset:    .long   0
                    150: savearea:      .long   0,0     # sp & bp to return to
                    151:        .text
                    152:        .globl _wait
                    153: 
                    154: __rtt:
                    155:        pushl   $1000000
                    156:        call    _wait
                    157:        popl    %eax
                    158:        movl    $-7,%eax
                    159:        jmp     1f
1.1.1.2 ! root      160: 
1.1       root      161: _exit:
1.1.1.2 ! root      162:        pushl   $1000000
        !           163:        call    _wait
        !           164:        popl    %eax
1.1       root      165:        movl    4(%esp),%eax
                    166: 1:
                    167: #ifdef REL
                    168: #ifndef SMALL
                    169:        call    _reset_cpu
                    170: #endif
                    171:        movw    $0x1234,%ax
                    172:        movw    %ax,0x472       # warm boot
                    173:        movl    $0,%esp         # segment violation
                    174:        ret
                    175: #else
                    176:        movl    savearea,%esp
                    177:        movl    savearea+4,%ebp
                    178:        ret
                    179: #endif
                    180: 
                    181:        .globl  _inb
                    182: _inb:  movl    4(%esp),%edx
                    183:        subl    %eax,%eax       # clr eax
1.1.1.2 ! root      184:        jmp 7f ; nop ; 7: jmp 7f ; nop ; 7: ;
1.1       root      185:        inb     %dx,%al
1.1.1.2 ! root      186:        jmp 7f ; nop ; 7: jmp 7f ; nop ; 7: ;
1.1       root      187:        ret
                    188: 
                    189:        .globl  _outb
                    190: _outb: movl    4(%esp),%edx
                    191:        movl    8(%esp),%eax
1.1.1.2 ! root      192:        jmp 7f ; nop ; 7: jmp 7f ; nop ; 7: ;
1.1       root      193:        outb    %al,%dx
1.1.1.2 ! root      194:        jmp 7f ; nop ; 7: jmp 7f ; nop ; 7: ;
1.1       root      195:        ret
                    196: 
                    197:        .globl ___udivsi3
                    198: ___udivsi3:
                    199:        movl 4(%esp),%eax
                    200:        xorl %edx,%edx
                    201:        divl 8(%esp)
                    202:        ret
                    203: 
                    204:        .globl ___divsi3
                    205: ___divsi3:
                    206:        movl 4(%esp),%eax
                    207:        xorl %edx,%edx
                    208:        cltd
                    209:        idivl 8(%esp)
                    210:        ret
                    211: 
                    212:        #
                    213:        # bzero (base,cnt)
                    214:        #
                    215: 
                    216:        .globl _bzero
                    217: _bzero:
                    218:        pushl   %edi
                    219:        movl    8(%esp),%edi
                    220:        movl    12(%esp),%ecx
                    221:        movb    $0x00,%al
                    222:        cld
                    223:        rep
                    224:        stosb
                    225:        popl    %edi
                    226:        ret
                    227: 
                    228:        #
                    229:        # bcopy (src,dst,cnt)
                    230:        # NOTE: does not (yet) handle overlapped copies
                    231:        #
                    232: 
                    233:        .globl  _bcopy
                    234: _bcopy:
                    235:        pushl   %esi
                    236:        pushl   %edi
                    237:        movl    12(%esp),%esi
                    238:        movl    16(%esp),%edi
                    239:        movl    20(%esp),%ecx
                    240:        cld
                    241:        rep
                    242:        movsb
                    243:        popl    %edi
                    244:        popl    %esi
                    245:        ret
                    246: 
                    247:        # insw(port,addr,cnt)
                    248:        .globl  _insw
                    249: _insw:
                    250:        pushl   %edi
                    251:        movw    8(%esp),%dx
                    252:        movl    12(%esp),%edi
                    253:        movl    16(%esp),%ecx
                    254:        cld
                    255:        nop
                    256:        .byte 0x66,0xf2,0x6d    # rep insw
                    257:        nop
                    258:        movl    %edi,%eax
                    259:        popl    %edi
                    260:        ret
                    261: 
                    262:        # outsw(port,addr,cnt)
                    263:        .globl  _outsw
                    264: _outsw:
                    265:        pushl   %esi
                    266:        movw    8(%esp),%dx
                    267:        movl    12(%esp),%esi
                    268:        movl    16(%esp),%ecx
                    269:        cld
                    270:        nop
                    271:        .byte 0x66,0xf2,0x6f    # rep outsw
                    272:        nop
                    273:        movl    %esi,%eax
                    274:        popl    %esi
                    275:        ret
                    276: 
1.1.1.2 ! root      277:        .globl _scream
        !           278: _scream: inb   $0x61,%al
        !           279:        orb     $3,%al
        !           280:        outb    %al, $0x61
        !           281:        ret

unix.superglobalmegacorp.com

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