]>
git.saurik.com Git - apple/xnu.git/blob - bsd/dev/unix_startup.c
   2  * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved. 
   4  * @APPLE_OSREFERENCE_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. The rights granted to you under the License 
  10  * may not be used to create, or enable the creation or redistribution of, 
  11  * unlawful or unlicensed copies of an Apple operating system, or to 
  12  * circumvent, violate, or enable the circumvention or violation of, any 
  13  * terms of an Apple operating system software license agreement. 
  15  * Please obtain a copy of the License at 
  16  * http://www.opensource.apple.com/apsl/ and read it before using this file. 
  18  * The Original Code and all software distributed under the License are 
  19  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 
  20  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 
  21  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 
  22  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 
  23  * Please see the License for the specific language governing rights and 
  24  * limitations under the License. 
  26  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 
  29  * Copyright (c) 1992,7 NeXT Computer, Inc. 
  31  * Unix data structure initialization. 
  35 #include <mach/mach_types.h> 
  37 #include <vm/vm_kern.h> 
  38 #include <mach/vm_prot.h> 
  40 #include <sys/param.h> 
  41 #include <sys/buf_internal.h> 
  42 #include <sys/clist.h> 
  44 #include <sys/systm.h> 
  46 #include <dev/ppc/cons.h> 
  48 extern vm_map_t mb_map
; 
  50 extern u_long   tcp_sendspace
; 
  51 extern u_long   tcp_recvspace
; 
  53 void            bsd_bufferinit(void); 
  54 extern void     md_prepare_for_shutdown(int, int, char *); 
  57  * Declare these as initialized data so we can patch them. 
  62 int             niobuf 
= NBUF 
/ 2; 
  70 int             srv 
= 0;        /* Flag indicates a server boot when set */ 
  74 vm_map_t        bufferhdr_map
; 
  77 extern void     bsd_startupearly(void); 
  80 bsd_startupearly(void) 
  82         vm_offset_t     firstaddr
; 
  87                 nbuf 
= atop(sane_size 
/ 100);   /* Get 1% of ram, but no more than we can map */ 
 100         size 
= (nbuf 
+ niobuf
) * sizeof(struct buf
); 
 101         size 
= round_page(size
); 
 103         ret 
= kmem_suballoc(kernel_map
, 
 110         if (ret 
!= KERN_SUCCESS
) 
 111                 panic("Failed to create bufferhdr_map"); 
 113         ret 
= kernel_memory_allocate(bufferhdr_map
, 
 117                                      KMA_HERE 
| KMA_KOBJECT
); 
 119         if (ret 
!= KERN_SUCCESS
) 
 120                 panic("Failed to allocate bufferhdr_map"); 
 122         buf 
= (struct buf 
*) firstaddr
; 
 125         if (sane_size 
> (64 * 1024 * 1024) || ncl
) { 
 128                 if ((nmbclusters 
= ncl
) == 0) { 
 129                         if ((nmbclusters 
= ((sane_size 
/ 16)/MCLBYTES
)) > 32768) 
 132                 if ((scale 
= nmbclusters 
/ NMBCLUSTERS
) > 1) { 
 133                         tcp_sendspace 
*= scale
; 
 134                         tcp_recvspace 
*= scale
; 
 136                         if (tcp_sendspace 
> (32 * 1024)) 
 137                                 tcp_sendspace 
= 32 * 1024; 
 138                         if (tcp_recvspace 
> (32 * 1024)) 
 139                                 tcp_recvspace 
= 32 * 1024; 
 149         cons
.t_dev 
= makedev(12, 0); 
 153         ret 
= kmem_suballoc(kernel_map
, 
 154                             (vm_offset_t 
*) & mbutl
, 
 155                             (vm_size_t
) (nmbclusters 
* MCLBYTES
), 
 160         if (ret 
!= KERN_SUCCESS
) 
 161                 panic("Failed to allocate mb_map\n"); 
 164          * Set up buffers, so they can be used to read disk labels.