]>
git.saurik.com Git - apple/xnu.git/blob - bsd/dev/unix_startup.c
86cfdd66412582e60c82f2abb140d057cb14726d
2 * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
31 * Copyright (c) 1992,7 NeXT Computer, Inc.
33 * Unix data structure initialization.
37 #include <mach/mach_types.h>
39 #include <vm/vm_kern.h>
40 #include <mach/vm_prot.h>
42 #include <sys/param.h>
43 #include <sys/buf_internal.h>
44 #include <sys/clist.h>
46 #include <sys/systm.h>
48 #include <dev/ppc/cons.h>
50 extern vm_map_t mb_map
;
52 extern u_long tcp_sendspace
;
53 extern u_long tcp_recvspace
;
55 void bsd_bufferinit(void);
56 extern void md_prepare_for_shutdown(int, int, char *);
59 * Declare these as initialized data so we can patch them.
64 int niobuf
= NBUF
/ 2;
72 int srv
= 0; /* Flag indicates a server boot when set */
76 vm_map_t bufferhdr_map
;
79 extern void bsd_startupearly(void);
82 bsd_startupearly(void)
84 vm_offset_t firstaddr
;
89 nbuf
= atop(sane_size
/ 100); /* Get 1% of ram, but no more than we can map */
102 size
= (nbuf
+ niobuf
) * sizeof(struct buf
);
103 size
= round_page(size
);
105 ret
= kmem_suballoc(kernel_map
,
112 if (ret
!= KERN_SUCCESS
)
113 panic("Failed to create bufferhdr_map");
115 ret
= kernel_memory_allocate(bufferhdr_map
,
119 KMA_HERE
| KMA_KOBJECT
);
121 if (ret
!= KERN_SUCCESS
)
122 panic("Failed to allocate bufferhdr_map");
124 buf
= (struct buf
*) firstaddr
;
127 if (sane_size
> (64 * 1024 * 1024) || ncl
) {
130 if ((nmbclusters
= ncl
) == 0) {
131 if ((nmbclusters
= ((sane_size
/ 16)/MCLBYTES
)) > 32768)
134 if ((scale
= nmbclusters
/ NMBCLUSTERS
) > 1) {
135 tcp_sendspace
*= scale
;
136 tcp_recvspace
*= scale
;
138 if (tcp_sendspace
> (32 * 1024))
139 tcp_sendspace
= 32 * 1024;
140 if (tcp_recvspace
> (32 * 1024))
141 tcp_recvspace
= 32 * 1024;
151 cons
.t_dev
= makedev(12, 0);
155 ret
= kmem_suballoc(kernel_map
,
156 (vm_offset_t
*) & mbutl
,
157 (vm_size_t
) (nmbclusters
* MCLBYTES
),
162 if (ret
!= KERN_SUCCESS
)
163 panic("Failed to allocate mb_map\n");
166 * Set up buffers, so they can be used to read disk labels.