|
|
1.1 ! root 1: /* netboot ! 2: * ! 3: * asm.s,v ! 4: # Revision 1.1 1993/07/08 16:03:50 brezak ! 5: # Diskless boot prom code from Jim McKim ([email protected]) ! 6: # ! 7: * Revision 1.3 1993/06/08 14:22:36 mckim ! 8: * Fast in line assembly bcopy(), bzero(). ! 9: * ! 10: * Revision 1.2 1993/05/28 20:01:26 mckim ! 11: * Fixed various StartProg() problems. ! 12: * ! 13: * Revision 1.1.1.1 1993/05/28 11:41:08 mckim ! 14: * Initial version. ! 15: * ! 16: * ! 17: * source in this file came from ! 18: * the 386BSD boot blocks written by Julian Elischer. ! 19: * ! 20: * Ported to boot 386BSD by Julian Elischer ([email protected]) Sept 1992 ! 21: * ! 22: * Mach Operating System ! 23: * Copyright (c) 1992, 1991 Carnegie Mellon University ! 24: * All Rights Reserved. ! 25: * ! 26: * Permission to use, copy, modify and distribute this software and its ! 27: * documentation is hereby granted, provided that both the copyright ! 28: * notice and this permission notice appear in all copies of the ! 29: * software, derivative works or modified versions, and any portions ! 30: * thereof, and that both notices appear in supporting documentation. ! 31: * ! 32: * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" ! 33: * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR ! 34: * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. ! 35: * ! 36: * Carnegie Mellon requests users of this software to return to ! 37: * ! 38: * Software Distribution Coordinator or [email protected] ! 39: * School of Computer Science ! 40: * Carnegie Mellon University ! 41: * Pittsburgh PA 15213-3890 ! 42: * ! 43: * any improvements or extensions that they make and grant Carnegie Mellon ! 44: * the rights to redistribute these changes. ! 45: */ ! 46: ! 47: /* ! 48: Copyright 1988, 1989, 1990, 1991, 1992 ! 49: by Intel Corporation, Santa Clara, California. ! 50: ! 51: All Rights Reserved ! 52: ! 53: Permission to use, copy, modify, and distribute this software and ! 54: its documentation for any purpose and without fee is hereby ! 55: granted, provided that the above copyright notice appears in all ! 56: copies and that both the copyright notice and this permission notice ! 57: appear in supporting documentation, and that the name of Intel ! 58: not be used in advertising or publicity pertaining to distribution ! 59: of the software without specific, written prior permission. ! 60: ! 61: INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE ! 62: INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, ! 63: IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR ! 64: CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM ! 65: LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, ! 66: NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION ! 67: WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ! 68: */ ! 69: ! 70: /*- ! 71: * Copyright (c) 1990 The Regents of the University of California. ! 72: * All rights reserved. ! 73: * ! 74: * This code is derived from software contributed to Berkeley by ! 75: * William Jolitz. ! 76: * ! 77: * Redistribution and use in source and binary forms, with or without ! 78: * modification, are permitted provided that the following conditions ! 79: * are met: ! 80: * 1. Redistributions of source code must retain the above copyright ! 81: * notice, this list of conditions and the following disclaimer. ! 82: * 2. Redistributions in binary form must reproduce the above copyright ! 83: * notice, this list of conditions and the following disclaimer in the ! 84: * documentation and/or other materials provided with the distribution. ! 85: * 3. All advertising materials mentioning features or use of this software ! 86: * must display the following acknowledgement: ! 87: * This product includes software developed by the University of ! 88: * California, Berkeley and its contributors. ! 89: * 4. Neither the name of the University nor the names of its contributors ! 90: * may be used to endorse or promote products derived from this software ! 91: * without specific prior written permission. ! 92: * ! 93: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ! 94: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ! 95: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ! 96: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE ! 97: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ! 98: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ! 99: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! 100: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ! 101: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ! 102: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ! 103: * SUCH DAMAGE. ! 104: */ ! 105: ! 106: .file "asm.s" ! 107: ! 108: #include "asm.h" ! 109: ! 110: .text ! 111: ! 112: ENTRY(StartProg) ! 113: /* void StartProg(u_long phyaddr, u_long *args) ! 114: * start the program in protected mode. phyaddr is the entry point. ! 115: */ ! 116: ! 117: #ifndef USE_BUFFER ! 118: push %ebp ! 119: mov %esp, %ebp ! 120: ! 121: # get things we need into registers ! 122: movl 0x8(%ebp), %ecx # entry offset ! 123: movl 0x0c(%ebp), %eax # &argv ! 124: ! 125: # make a new stack at 0:0xa0000 (big segs) ! 126: mov $KERN_DATA_SEG, %ebx ! 127: movw %bx, %ss ! 128: movl $0xa0000,%ebx ! 129: movl %ebx,%esp ! 130: ! 131: ! 132: # push some number of args onto the stack ! 133: pushl $0 # nominally a cyl offset in the boot. ! 134: pushl 0x8(%eax) # argv[2] = bootdev ! 135: pushl 0x4(%eax) # argv[1] = howto ! 136: pushl $0 # dummy 'return' address ! 137: ! 138: # push on our entry address ! 139: mov $KERN_CODE_SEG, %ebx # segment ! 140: pushl %ebx ! 141: pushl %ecx ! 142: ! 143: # convert over the other data segs ! 144: mov $KERN_DATA_SEG, %ebx ! 145: movw %bx, %ds ! 146: movw %bx, %es ! 147: ! 148: # convert the PC (and code seg) ! 149: lret ! 150: #else ! 151: /* test version - relocating, kernel move (TBD) */ ! 152: /* if necessary, move ourself out of the way ! 153: * move the copy of the kernel to its correct load point ! 154: * set up a stack and transfer args to it ! 155: * call the entry point ! 156: * this is best done in assembly as the potential relocation will ! 157: * have a bad effect on non-PIC code. ! 158: */ ! 159: /* get things we need into registers */ ! 160: movl 0x8(%ebp), %ecx # entry offset ! 161: movl 0x0c(%ebp), %eax # &argv ! 162: ! 163: /* relocate ourselves to <tmp_reloc_org> */ ! 164: # PhysBcopy(RELOC, tmp_reloc_org, WORK_AREA_SIZE); ! 165: mov $RELOC, %esi ! 166: mov $tmp_reloc_org, %edi ! 167: mov $WORK_AREA_SIZE, %ecx ! 168: mov %ds, %ax ! 169: mov %ax, %es ! 170: rep ! 171: movsb ! 172: ! 173: /* TBD - could probably also do this by munging a seg descriptor. ! 174: * would it be easier? ! 175: */ ! 176: ljmp $KERN_CODE_SEG, tmp_reloc_org+$1f ! 177: 1: ! 178: /* now we are PIC - caveats */ ! 179: /* move the stack pointer to the new copy */ ! 180: add tmp_reloc_org-xxx, %esp ! 181: ! 182: /* push some number of args onto the stack */ ! 183: pushl $0 # nominally a cyl offset in the boot. ! 184: pushl 0x8(%eax) # argv[2] = bootdev ! 185: pushl 0x4(%eax) # argv[1] = howto ! 186: pushl $0 # dummy 'return' address ! 187: ! 188: /* push on our entry address */ ! 189: mov $0x08, %ebx # segment ! 190: pushl %ebx ! 191: pushl %ecx ! 192: ! 193: /* copy loaded file to its destination (TBD) */ ! 194: # PhysBcopy(kcopy, korg, ksize); ! 195: mov kern_copy_org, %esi ! 196: mov boot_area_org, %edi ! 197: mov xxxksize, %ecx ! 198: mov %ds, %ax ! 199: mov %ax, %es ! 200: rep ! 201: movsb ! 202: ! 203: /* convert the PC (and code seg) */ ! 204: lret ! 205: #endif ! 206: ! 207: ! 208: /* ! 209: * C library -- _setjmp, _longjmp ! 210: * ! 211: * longjmp(a,v) ! 212: * will generate a "return(v)" from the last call to ! 213: * setjmp(a) ! 214: * by restoring registers from the stack. ! 215: * The previous signal state is restored. ! 216: */ ! 217: ! 218: ENTRY(setjmp) ! 219: movl 4(%esp),%ecx ! 220: movl 0(%esp),%edx ! 221: movl %edx, 0(%ecx) ! 222: movl %ebx, 4(%ecx) ! 223: movl %esp, 8(%ecx) ! 224: movl %ebp,12(%ecx) ! 225: movl %esi,16(%ecx) ! 226: movl %edi,20(%ecx) ! 227: movl %eax,24(%ecx) ! 228: movl $0,%eax ! 229: ret ! 230: ! 231: ENTRY(longjmp) ! 232: movl 4(%esp),%edx ! 233: movl 8(%esp),%eax ! 234: movl 0(%edx),%ecx ! 235: movl 4(%edx),%ebx ! 236: movl 8(%edx),%esp ! 237: movl 12(%edx),%ebp ! 238: movl 16(%edx),%esi ! 239: movl 20(%edx),%edi ! 240: cmpl $0,%eax ! 241: jne 1f ! 242: movl $1,%eax ! 243: 1: movl %ecx,0(%esp) ! 244: ret
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.