2 * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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
22 * @APPLE_LICENSE_HEADER_END@
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.
33 * bootu() -- second stage boot.
35 * This function must be located at 0:BOOTER_ADDR and will be called
39 #include <architecture/i386/asm_help.h>
42 #define data32 .byte 0x66
43 #define addr32 .byte 0x67
44 #define retf .byte 0xcb
50 EXPORT(_chainbootdev) .byte 0x80
51 EXPORT(_chainbootflag) .byte 0x00
55 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
56 # Booter entry point. Called by the MBR booter.
57 # This routine must be the first in the TEXT segment.
60 # DL = Boot drive number
61 # SI = Pointer to partition table entry.
64 pushl %ecx # Save general purpose registers
69 push %ds # Save DS, ES
72 mov %cs, %ax # Update segment registers.
73 mov %ax, %ds # Set DS and ES to match CS
77 mov %si, %bx # save si
80 call __switch_stack # Switch to new stack
83 call __real_to_prot # Enter protected mode.
85 # We are now in 32-bit protected mode.
86 # Transfer execution to C by calling boot().
94 movb _chainbootdev, %dl # Setup DL with the BIOS device number
96 call __prot_to_real # Back to real mode.
99 call __switch_stack # Restore original stack
101 pop %es # Restore original ES and DS
103 popl %edi # Restore all general purpose registers
104 popl %esi # except EAX.
110 ljmp $0x2000, $0x0200 # Jump to boot code already in memory