]>
git.saurik.com Git - apple/xnu.git/blob - bsd/dev/unix_startup.c
fc8bb8f41f87caf076a620a56a298a16fc199c33
2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
24 * Copyright (c) 1992,7 NeXT Computer, Inc.
26 * Unix data structure initialization.
30 #include <mach/mach_types.h>
32 #include <vm/vm_kern.h>
33 #include <mach/vm_prot.h>
35 #include <sys/param.h>
36 #include <sys/buf_internal.h>
37 #include <sys/clist.h>
39 #include <sys/systm.h>
41 #include <dev/ppc/cons.h>
43 extern vm_map_t mb_map
;
45 extern u_long tcp_sendspace
;
46 extern u_long tcp_recvspace
;
48 void bsd_bufferinit(void);
49 extern void md_prepare_for_shutdown(int, int, char *);
52 * Declare these as initialized data so we can patch them.
57 int niobuf
= NBUF
/ 2;
65 int srv
= 0; /* Flag indicates a server boot when set */
69 vm_map_t bufferhdr_map
;
72 extern void bsd_startupearly(void);
75 bsd_startupearly(void)
77 vm_offset_t firstaddr
;
82 nbuf
= atop(sane_size
/ 100); /* Get 1% of ram, but no more than we can map */
95 size
= (nbuf
+ niobuf
) * sizeof(struct buf
);
96 size
= round_page(size
);
98 ret
= kmem_suballoc(kernel_map
,
105 if (ret
!= KERN_SUCCESS
)
106 panic("Failed to create bufferhdr_map");
108 ret
= kernel_memory_allocate(bufferhdr_map
,
112 KMA_HERE
| KMA_KOBJECT
);
114 if (ret
!= KERN_SUCCESS
)
115 panic("Failed to allocate bufferhdr_map");
117 buf
= (struct buf
*) firstaddr
;
120 if (sane_size
> (64 * 1024 * 1024) || ncl
) {
123 if ((nmbclusters
= ncl
) == 0) {
124 if ((nmbclusters
= ((sane_size
/ 16)/MCLBYTES
)) > 32768)
127 if ((scale
= nmbclusters
/ NMBCLUSTERS
) > 1) {
128 tcp_sendspace
*= scale
;
129 tcp_recvspace
*= scale
;
131 if (tcp_sendspace
> (32 * 1024))
132 tcp_sendspace
= 32 * 1024;
133 if (tcp_recvspace
> (32 * 1024))
134 tcp_recvspace
= 32 * 1024;
144 cons
.t_dev
= makedev(12, 0);
148 ret
= kmem_suballoc(kernel_map
,
149 (vm_offset_t
*) & mbutl
,
150 (vm_size_t
) (nmbclusters
* MCLBYTES
),
155 if (ret
!= KERN_SUCCESS
)
156 panic("Failed to allocate mb_map\n");
159 * Set up buffers, so they can be used to read disk labels.