]> git.saurik.com Git - apple/boot.git/blob - i386/boot2/boot2.s
ec1657258f22a6fb629b9ab13da12a9d538d122e
[apple/boot.git] / i386 / boot2 / boot2.s
1 /*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.1 (the "License"). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
12 * this file.
13 *
14 * The Original Code and all software distributed under the License are
15 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
20 * under the License.
21 *
22 * @APPLE_LICENSE_HEADER_END@
23 */
24 /*
25 * Mach Operating System
26 * Copyright (c) 1990 Carnegie-Mellon University
27 * Copyright (c) 1989 Carnegie-Mellon University
28 * All rights reserved. The CMU software License Agreement specifies
29 * the terms and conditions for use and redistribution.
30 */
31
32 /*
33 * boot2() -- second stage boot.
34 *
35 * This function must be located at 0:BOOTER_ADDR and will be called
36 * by boot1 or by NBP.
37 */
38
39 #include <architecture/i386/asm_help.h>
40 #include "memory.h"
41
42 #define data32 .byte 0x66
43 #define retf .byte 0xcb
44
45
46 .file "boot2.s"
47
48 .text
49
50 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
51 # Booter entry point. Called by boot1 or by the NBP.
52 # This routine must be the first in the TEXT segment.
53 #
54 # Arguments:
55 # DX = Boot device
56 #
57 # Returns:
58 #
59 LABEL(boot2)
60 pushl %ecx # Save general purpose registers
61 pushl %ebx
62 pushl %ebp
63 pushl %esi
64 pushl %edi
65 push %ds # Save DS, ES
66 push %es
67
68 mov %cs, %ax # Update segment registers.
69 mov %ax, %ds # Set DS and ES to match CS
70 mov %ax, %es
71
72 data32
73 call __switch_stack # Switch to new stack
74
75 data32
76 call __real_to_prot # Enter protected mode.
77
78 # We are now in 32-bit protected mode.
79 # Transfer execution to C by calling boot().
80
81 pushl %edx # bootdev
82 call _boot
83
84 call __prot_to_real # Back to real mode.
85
86 data32
87 call __switch_stack # Restore original stack
88
89 pop %es # Restore original ES and DS
90 pop %ds
91 popl %edi # Restore all general purpose registers
92 popl %esi # except EAX.
93 popl %ebp
94 popl %ebx
95 popl %ecx
96
97 retf # Hardcode a far return
98