]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
43866e37 | 6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. |
1c79356b | 7 | * |
43866e37 A |
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 | |
1c79356b A |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
43866e37 A |
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. | |
1c79356b A |
22 | * |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | /* | |
26 | * Copyright (c) 1992,7 NeXT Computer, Inc. | |
27 | * | |
28 | * Unix data structure initialization. | |
29 | */ | |
30 | ||
31 | #include <mach/mach_types.h> | |
32 | ||
33 | #include <vm/vm_kern.h> | |
34 | #include <mach/vm_prot.h> | |
35 | ||
36 | #include <sys/param.h> | |
37 | #include <sys/buf.h> | |
38 | #include <sys/clist.h> | |
39 | #include <sys/mbuf.h> | |
40 | #include <sys/systm.h> | |
41 | #include <sys/tty.h> | |
42 | #include <dev/ppc/cons.h> | |
43 | ||
44 | extern vm_map_t mb_map; | |
45 | ||
46 | /* | |
47 | * Declare these as initialized data so we can patch them. | |
48 | */ | |
49 | ||
50 | #ifdef NBUF | |
51 | int nbuf = NBUF; | |
52 | int niobuf = NBUF/2; | |
53 | #else | |
54 | int nbuf = 0; | |
55 | int niobuf = 0; | |
56 | #endif | |
57 | ||
58 | int srv = 0; /* Flag indicates a server boot when set */ | |
59 | int ncl = 0; | |
60 | ||
61 | vm_map_t bufferhdr_map; | |
62 | ||
63 | void | |
64 | bsd_startupearly() | |
65 | { | |
66 | vm_offset_t firstaddr; | |
67 | vm_size_t size; | |
68 | kern_return_t ret; | |
69 | ||
70 | if (nbuf == 0) | |
de355530 | 71 | nbuf = atop(mem_size / 100); /* 1% */ |
1c79356b A |
72 | if (nbuf > 8192) |
73 | nbuf = 8192; | |
74 | if (nbuf < 256) | |
75 | nbuf = 256; | |
76 | ||
77 | if (niobuf == 0) | |
9bccf70c | 78 | niobuf = nbuf; |
1c79356b A |
79 | if (niobuf > 4096) |
80 | niobuf = 4096; | |
81 | if (niobuf < 128) | |
82 | niobuf = 128; | |
83 | ||
84 | size = (nbuf + niobuf) * sizeof (struct buf); | |
de355530 | 85 | size = round_page(size); |
1c79356b A |
86 | |
87 | ret = kmem_suballoc(kernel_map, | |
88 | &firstaddr, | |
89 | size, | |
90 | FALSE, | |
91 | TRUE, | |
92 | &bufferhdr_map); | |
93 | ||
94 | if (ret != KERN_SUCCESS) | |
95 | panic("Failed to create bufferhdr_map"); | |
96 | ||
97 | ret = kernel_memory_allocate(bufferhdr_map, | |
98 | &firstaddr, | |
99 | size, | |
100 | 0, | |
101 | KMA_HERE | KMA_KOBJECT); | |
102 | ||
103 | if (ret != KERN_SUCCESS) | |
104 | panic("Failed to allocate bufferhdr_map"); | |
105 | ||
106 | buf = (struct buf * )firstaddr; | |
107 | bzero(buf,size); | |
108 | ||
de355530 | 109 | if ((mem_size > (64 * 1024 * 1024)) || ncl) { |
1c79356b A |
110 | int scale; |
111 | extern u_long tcp_sendspace; | |
112 | extern u_long tcp_recvspace; | |
113 | ||
114 | if ((nmbclusters = ncl) == 0) { | |
de355530 | 115 | if ((nmbclusters = ((mem_size / 16) / MCLBYTES)) > 16384) |
9bccf70c | 116 | nmbclusters = 16384; |
1c79356b A |
117 | } |
118 | if ((scale = nmbclusters / NMBCLUSTERS) > 1) { | |
119 | tcp_sendspace *= scale; | |
120 | tcp_recvspace *= scale; | |
121 | ||
122 | if (tcp_sendspace > (32 * 1024)) | |
123 | tcp_sendspace = 32 * 1024; | |
124 | if (tcp_recvspace > (32 * 1024)) | |
125 | tcp_recvspace = 32 * 1024; | |
126 | } | |
127 | } | |
128 | } | |
129 | ||
130 | void | |
131 | bsd_bufferinit() | |
132 | { | |
133 | kern_return_t ret; | |
134 | ||
135 | cons.t_dev = makedev(12, 0); | |
136 | ||
137 | bsd_startupearly(); | |
138 | ||
139 | ret = kmem_suballoc(kernel_map, | |
140 | &mbutl, | |
141 | (vm_size_t) (nmbclusters * MCLBYTES), | |
142 | FALSE, | |
143 | TRUE, | |
144 | &mb_map); | |
145 | ||
146 | if (ret != KERN_SUCCESS) | |
147 | panic("Failed to allocate mb_map\n"); | |
148 | ||
149 | /* | |
150 | * Set up buffers, so they can be used to read disk labels. | |
151 | */ | |
152 | bufinit(); | |
153 | } | |
154 | ||
0b4e3aa0 A |
155 | void |
156 | md_prepare_for_shutdown(int paniced, int howto, char * command) | |
157 | { | |
158 | extern void IOSystemShutdownNotification(); | |
159 | ||
160 | /* | |
161 | * Temporary hack to notify the power management root domain | |
162 | * that the system will shut down. | |
163 | */ | |
164 | IOSystemShutdownNotification(); | |
165 | } |