Root/
Source at commit 1335 created 12 years 10 months ago. By azimutz, Old ati.c changes: - auto switch framebuffer according to OS version (pre/post 10.6.8) - add AtiConfig key, plus verbose messages - small "clean up" | |
---|---|
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 <stdio.h>␊ |
54 | ␊ |
55 | #include "boot.h"␊ |
56 | #include "memory.h"␊ |
57 | ␊ |
58 | extern void init_module_system();␊ |
59 | extern int execute_hook(const char* name, void*, void*, void*, void*);␊ |
60 | ␊ |
61 | extern void bzero(void * dst, size_t len);␊ |
62 | extern void enableA20(void);␊ |
63 | extern void video_mode(int mode);␊ |
64 | extern void malloc_init(char * start, int size, int nodes, void (*malloc_error)(char *, size_t, const char *, int));␊ |
65 | ␊ |
66 | //==========================================================================␊ |
67 | // Zero the BSS.␊ |
68 | ␊ |
69 | static void zeroBSS(void)␊ |
70 | {␊ |
71 | ␉extern char _DATA__bss__begin, _DATA__bss__end;␊ |
72 | ␉extern char _DATA__common__begin, _DATA__common__end;␊ |
73 | ␊ |
74 | ␉bzero(&_DATA__bss__begin, (&_DATA__bss__end - &_DATA__bss__begin));␊ |
75 | ␉bzero(&_DATA__common__begin, (&_DATA__common__end - &_DATA__common__begin));␊ |
76 | }␊ |
77 | ␊ |
78 | //==========================================================================␊ |
79 | // Malloc error function␊ |
80 | ␊ |
81 | static void malloc_error(char *addr, size_t size, const char *file, int line)␊ |
82 | {␊ |
83 | ␉printf("\nMemory allocation error! Addr=0x%x, Size=0x%x, File=%s, Line=%d\n", (unsigned)addr, (unsigned)size, file, line);␊ |
84 | ␉while(1);␊ |
85 | }␊ |
86 | ␊ |
87 | //==========================================================================␊ |
88 | //Initializes the runtime. Right now this means zeroing the BSS and initializing malloc.␊ |
89 | //␊ |
90 | void initialize_runtime(void)␊ |
91 | {␊ |
92 | ␉zeroBSS();␊ |
93 | ␉malloc_init((void*)ZALLOC_ADDR, ZALLOC_LEN, 16384, malloc_error);␊ |
94 | }␊ |
95 | ␊ |
96 | //==========================================================================␊ |
97 | // The 'main' function for the booter. Called by boot0 when booting␊ |
98 | // from a block device, or by the network booter.␊ |
99 | //␊ |
100 | // arguments:␊ |
101 | // biosdev - Value passed from boot1/NBP to specify the device␊ |
102 | // that the booter was loaded from.␊ |
103 | void common_boot(int biosdev)␊ |
104 | {␊ |
105 | ␉int loopCount = 0;␊ |
106 | ␊ |
107 | video_mode( 2 ); // 80x25 mono text mode.␊ |
108 | ␊ |
109 | ␉// Intialize module system ␊ |
110 | ␉init_module_system();␊ |
111 | ␊ |
112 | ␉execute_hook("Initialize", (void*)loopCount++, (void*)biosdev, 0, 0);␉// Main work loop␊ |
113 | ␉␊ |
114 | while(1)␊ |
115 | {␊ |
116 | execute_hook("WorkLoop", (void*)loopCount++, (void*)biosdev, 0, 0);␉// Main work loop␊ |
117 | }␉␊ |
118 | }␊ |
119 | ␊ |
120 | //==========================================================================␊ |
121 | // This is the entrypoint from real.␊ |
122 | void boot(int biosdev)␊ |
123 | {␊ |
124 | ␉initialize_runtime();␊ |
125 | ␉// Enable A20 gate before accessing memory above 1Mb.␊ |
126 | ␉enableA20();␊ |
127 | ␉common_boot(biosdev);␊ |
128 | }␊ |
129 |