Chameleon

Chameleon Svn Source Tree

Root/branches/rewrite/i386/boot2/boot.c

Source at commit 1066 created 12 years 9 months ago.
By meklort, Removing even more code...
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 * INTEL CORPORATION PROPRIETARY INFORMATION
34 *
35 * This software is supplied under the terms of a license agreement or
36 * nondisclosure agreement with Intel Corporation and may not be copied
37 * nor disclosed except in accordance with the terms of that agreement.
38 *
39 * Copyright 1988, 1989 by Intel Corporation
40 */
41
42/*
43 * Copyright 1993 NeXT Computer, Inc.
44 * All rights reserved.
45 */
46
47/*
48 * Completely reworked by Sam Streeper (sam_s@NeXT.com)
49 * Reworked again by Curtis Galloway (galloway@NeXT.com)
50 */
51
52
53#include "boot.h"
54#include "sl.h"
55#include "libsa.h"
56#include "platform.h"
57#include "modules.h"
58
59long gBootMode; /* defaults to 0 == kBootModeNormal */
60bool gOverrideKernel;
61char *gPlatformName;
62char gRootDevice[512];
63char gMKextName[512];
64char gMacOSVersion[8];
65bool gEnableCDROMRescan;
66bool gScanSingleDrive;
67
68int bvCount = 0;
69int gDeviceCount = 0;
70
71BVRef bvr;
72BVRef menuBVR;
73BVRef bvChain;
74bool useGUI;
75
76/*
77 * How long to wait (in seconds) to load the
78 * kernel after displaying the "boot:" prompt.
79 */
80#define kBootErrorTimeout 5
81
82/*
83 * Default path to kernel cache file
84 */
85//Slice - first one for Leopard
86#define kDefaultCachePathLeo "/System/Library/Caches/com.apple.kernelcaches/"
87#define kDefaultCachePathSnow "/System/Library/Caches/com.apple.kext.caches/Startup/"
88
89//==========================================================================
90// Zero the BSS.
91
92static void zeroBSS(void)
93{
94extern char _DATA__bss__begin, _DATA__bss__end;
95extern char _DATA__common__begin, _DATA__common__end;
96
97bzero(&_DATA__bss__begin, (&_DATA__bss__end - &_DATA__bss__begin));
98bzero(&_DATA__common__begin, (&_DATA__common__end - &_DATA__common__begin));
99}
100
101//==========================================================================
102// Malloc error function
103
104static void malloc_error(char *addr, size_t size, const char *file, int line)
105{
106stop("\nMemory allocation error! Addr=0x%x, Size=0x%x, File=%s, Line=%d\n", (unsigned)addr, (unsigned)size, file, line);
107}
108
109//==========================================================================
110//Initializes the runtime. Right now this means zeroing the BSS and initializing malloc.
111//
112void initialize_runtime(void)
113{
114zeroBSS();
115malloc_init(0, 0, 0, malloc_error);
116}
117
118//==========================================================================
119// This is the entrypoint from real-mode which functions exactly as it did
120// before. Multiboot does its own runtime initialization, does some of its
121// own things, and then calls common_boot.
122void boot(int biosdev)
123{
124initialize_runtime();
125// Enable A20 gate before accessing memory above 1Mb.
126enableA20();
127common_boot(biosdev);
128}
129
130//==========================================================================
131// The 'main' function for the booter. Called by boot0 when booting
132// from a block device, or by the network booter.
133//
134// arguments:
135// biosdev - Value passed from boot1/NBP to specify the device
136// that the booter was loaded from.
137//
138// If biosdev is kBIOSDevNetwork, then this function will return if
139// booting was unsuccessful. This allows the PXE firmware to try the
140// next boot device on its list.
141void common_boot(int biosdev)
142{
143 //unsigned int allowBVFlags = kBVFlagSystemVolume|kBVFlagForeignBoot;
144// unsigned int denyBVFlags = kBVFlagEFISystem;
145
146 // Setup VGA text mode.
147 // Not sure if it is safe to call setVideoMode() before the
148 // config table has been loaded. Call video_mode() instead.
149 video_mode( 2 ); // 80x25 mono text mode.
150
151 // TOOD: move to a module
152 /*
153 // Scan and record the system's hardware information.
154 scan_platform();
155
156 // First get info for boot volume.
157 scanBootVolumes(gBIOSDev, 0);
158
159 bvChain = getBVChainForBIOSDev(gBIOSDev);
160
161 setBootGlobals(bvChain);
162
163 scanDisks(gBIOSDev, &bvCount);
164
165 // Create a separated bvr chain using the specified filters.
166 bvChain = newFilteredBVChain(0x80, 0xFF, allowBVFlags, denyBVFlags, &gDeviceCount);
167
168 gBootVolume = selectBootVolume(bvChain);
169 */
170// Intialize module system
171init_module_system();
172}

Archive Download this file

Revision: 1066