]> git.saurik.com Git - apple/boot.git/blob - i386/boot1u/boot.c
69859b29a8b6126b3ea49ae78eb7f14f3d3df5ec
[apple/boot.git] / i386 / boot1u / boot.c
1 /*
2 * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25
26 #include <libsa.h>
27 #include <libsa/memory.h>
28 #include <saio_types.h>
29 #include <saio_internal.h>
30
31 #include <fdisk.h>
32 #include <ufs.h>
33
34 #include "boot1u.h"
35 #include "disk.h"
36
37 #include <io_inline.h>
38
39 void *gFSLoadAddress;
40
41 //#define BOOT_FILE "/foo"
42 #define BOOT_FILE "/usr/standalone/i386/boot"
43
44
45 //==========================================================================
46 // Zero the BSS.
47
48 static void zeroBSS()
49 {
50 extern char _DATA__bss__begin, _DATA__bss__end;
51 extern char _DATA__common__begin, _DATA__common__end;
52
53 bzero( &_DATA__bss__begin,
54 (&_DATA__bss__end - &_DATA__bss__begin) );
55
56 bzero( &_DATA__common__begin,
57 (&_DATA__common__end - &_DATA__common__begin) );
58 }
59
60 struct BootVolume bv;
61
62 extern char chainbootdev;
63
64 void boot(int biosdev, void *partPtr)
65 {
66 struct fdisk_part part;
67 int cc;
68
69 zeroBSS();
70
71 // printf("Hello, world.\n");
72
73 // Enable A20 gate before accessing memory above 1Mb.
74 enableA20();
75
76 biosdev = biosdev & 0xFF;
77 chainbootdev = biosdev;
78
79 /* Don't believe the passed-in partition table */
80 cc = findUFSPartition(biosdev, &part);
81 if (cc<0) {
82 printf("No UFS partition\n");
83 halt();
84 }
85
86 initUFSBVRef(&bv, biosdev, &part);
87
88 gFSLoadAddress = (void *)BOOT2_ADDR;
89 cc = UFSLoadFile(&bv, BOOT_FILE);
90 if (cc < 0) {
91 printf("Could not load" BOOT_FILE "\n");
92 halt();
93 }
94 // Return to execute booter
95 }