1 /* $NetBSD: startprog.S,v 1.3 2003/02/01 14:48:18 dsl Exp $ */
3 /* starts program in protected mode / flat space
5 needs global variables flatcodeseg and flatdataseg
7 derived from: NetBSD:sys/arch/i386/boot/asm.S
11 * Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
13 * Mach Operating System
14 * Copyright (c) 1992, 1991 Carnegie Mellon University
15 * All Rights Reserved.
17 * Permission to use, copy, modify and distribute this software and its
18 * documentation is hereby granted, provided that both the copyright
19 * notice and this permission notice appear in all copies of the
20 * software, derivative works or modified versions, and any portions
21 * thereof, and that both notices appear in supporting documentation.
23 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
24 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
25 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
27 * Carnegie Mellon requests users of this software to return to
29 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
30 * School of Computer Science
31 * Carnegie Mellon University
32 * Pittsburgh PA 15213-3890
34 * any improvements or extensions that they make and grant Carnegie Mellon
35 * the rights to redistribute these changes.
39 Copyright 1988, 1989, 1990, 1991, 1992
40 by Intel Corporation, Santa Clara, California.
44 Permission to use, copy, modify, and distribute this software and
45 its documentation for any purpose and without fee is hereby
46 granted, provided that the above copyright notice appears in all
47 copies and that both the copyright notice and this permission notice
48 appear in supporting documentation, and that the name of Intel
49 not be used in advertising or publicity pertaining to distribution
50 of the software without specific, written prior permission.
52 INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
53 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
54 IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
55 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
56 LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
57 NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
58 WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
61 #include <machine/asm.h>
64 * startprog(phyaddr,argc,argv,stack)
65 * start the program on protected mode where phyaddr is the entry point
72 movl $flatdataseg, %ebx
73 movw %bx, %es # for arg copy
74 movl 20(%ebp), %eax # stack
78 # push some number of args onto the stack
79 movl 12(%ebp), %ecx # argc
84 addl 16(%ebp), %eax # ptr to last arg
91 cld # LynxOS depends on it
93 movl 8(%ebp), %ecx # entry
95 # set new stackptr (movsl decd sp 1 more -> dummy return address)
99 # push on our entry address
100 movl $flatcodeseg, %ebx # segment
104 # convert over the other data segs
105 movl $flatdataseg, %ebx
109 # convert the PC (and code seg)