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