]> git.saurik.com Git - apple/boot.git/blob - i386/boot1u/boot1u.s
boot-132.tar.gz
[apple/boot.git] / i386 / boot1u / boot1u.s
1 /*
2 * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Portions Copyright (c) 1999-2003 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 2.0 (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 * bootu() -- 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 addr32 .byte 0x67
44 #define retf .byte 0xcb
45
46 .file "bootu.s"
47
48 .data
49
50 EXPORT(_chainbootdev) .byte 0x80
51 EXPORT(_chainbootflag) .byte 0x00
52
53 .text
54
55 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
56 # Booter entry point. Called by the MBR booter.
57 # This routine must be the first in the TEXT segment.
58 #
59 # Arguments:
60 # DL = Boot drive number
61 # SI = Pointer to partition table entry.
62 #
63 LABEL(bootu)
64 pushl %ecx # Save general purpose registers
65 pushl %ebx
66 pushl %ebp
67 pushl %esi
68 pushl %edi
69 push %ds # Save DS, ES
70 push %es
71
72 mov %cs, %ax # Update segment registers.
73 mov %ax, %ds # Set DS and ES to match CS
74 mov %ax, %es
75
76 xor %ebx, %ebx
77 mov %si, %bx # save si
78
79 data32
80 call __switch_stack # Switch to new stack
81
82 data32
83 call __real_to_prot # Enter protected mode.
84
85 # We are now in 32-bit protected mode.
86 # Transfer execution to C by calling boot().
87
88 pushl %ebx
89 pushl %edx # bootdev
90 call _boot
91
92 start_boot2:
93 xorl %edx, %edx
94 movb _chainbootdev, %dl # Setup DL with the BIOS device number
95
96 call __prot_to_real # Back to real mode.
97
98 data32
99 call __switch_stack # Restore original stack
100
101 pop %es # Restore original ES and DS
102 pop %ds
103 popl %edi # Restore all general purpose registers
104 popl %esi # except EAX.
105 popl %ebp
106 popl %ebx
107 popl %ecx
108
109 data32
110 ljmp $0x2000, $0x0200 # Jump to boot code already in memory
111