1 /* $NetBSD: multiboot.S,v 1.1 2008/10/11 11:06:20 joerg Exp $ */
3 /* starts program in protected mode / flat space
5 needs global variables flatcodeseg and flatdataseg
7 derived from: NetBSD:sys/arch/i386/stand/lib/startprog.S
11 * Copyright (c) 2008 The NetBSD Foundation, Inc.
12 * All rights reserved.
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
23 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
24 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
27 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
37 * Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
39 * Mach Operating System
40 * Copyright (c) 1992, 1991 Carnegie Mellon University
41 * All Rights Reserved.
43 * Permission to use, copy, modify and distribute this software and its
44 * documentation is hereby granted, provided that both the copyright
45 * notice and this permission notice appear in all copies of the
46 * software, derivative works or modified versions, and any portions
47 * thereof, and that both notices appear in supporting documentation.
49 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
50 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
51 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
53 * Carnegie Mellon requests users of this software to return to
55 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
56 * School of Computer Science
57 * Carnegie Mellon University
58 * Pittsburgh PA 15213-3890
60 * any improvements or extensions that they make and grant Carnegie Mellon
61 * the rights to redistribute these changes.
65 Copyright 1988, 1989, 1990, 1991, 1992
66 by Intel Corporation, Santa Clara, California.
70 Permission to use, copy, modify, and distribute this software and
71 its documentation for any purpose and without fee is hereby
72 granted, provided that the above copyright notice appears in all
73 copies and that both the copyright notice and this permission notice
74 appear in supporting documentation, and that the name of Intel
75 not be used in advertising or publicity pertaining to distribution
76 of the software without specific, written prior permission.
78 INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
79 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
80 IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
81 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
82 LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
83 NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
84 WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
87 #include <machine/asm.h>
88 #define MULTIBOOT_INFO_MAGIC 0x2BADB002
91 * multiboot(phyaddr,header,stack)
92 * start the program on protected mode where phyaddr is the entry point
99 movl $flatdataseg, %eax
100 movw %ax, %es # for arg copy
101 movl 16(%ebp), %ebx # stack
105 movl 12(%ebp), %ebx # header
106 movl 8(%ebp), %ecx # entry
108 # set new stackptr (movsl decd sp 1 more -> dummy return address)
112 # push on our entry address
113 movl $flatcodeseg, %eax # segment
117 # convert over the other data segs
118 movl $flatdataseg, %eax
122 movl $MULTIBOOT_INFO_MAGIC, %eax
123 # convert the PC (and code seg)