]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
e5568f75 A |
6 | * The contents of this file constitute Original Code as defined in and |
7 | * are subject to the Apple Public Source License Version 1.1 (the | |
8 | * "License"). You may not use this file except in compliance with the | |
9 | * License. Please obtain a copy of the License at | |
10 | * http://www.apple.com/publicsource and read it before using this file. | |
1c79356b | 11 | * |
e5568f75 A |
12 | * This Original Code and all software distributed under the License are |
13 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
1c79356b A |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
e5568f75 A |
16 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the |
17 | * License for the specific language governing rights and limitations | |
18 | * under the License. | |
1c79356b A |
19 | * |
20 | * @APPLE_LICENSE_HEADER_END@ | |
21 | */ | |
22 | /* | |
23 | * Copyright (c) 1992,7 NeXT Computer, Inc. | |
24 | * | |
25 | * Unix data structure initialization. | |
26 | * | |
27 | */ | |
28 | ||
29 | #include <mach/mach_types.h> | |
30 | ||
31 | #include <vm/vm_kern.h> | |
32 | #include <mach/vm_prot.h> | |
33 | ||
34 | #include <sys/param.h> | |
35 | #include <sys/buf.h> | |
36 | #include <sys/clist.h> | |
37 | #include <sys/mbuf.h> | |
38 | #include <sys/systm.h> | |
39 | #include <sys/tty.h> | |
40 | #include <dev/ppc/cons.h> | |
41 | ||
42 | extern vm_map_t mb_map; | |
43 | ||
44 | /* | |
45 | * Declare these as initialized data so we can patch them. | |
46 | */ | |
47 | ||
48 | #ifdef NBUF | |
49 | int nbuf = NBUF; | |
50 | int niobuf = NBUF/2; | |
51 | #else | |
52 | int nbuf = 0; | |
53 | int niobuf = 0; | |
54 | #endif | |
55 | ||
56 | int srv = 0; /* Flag indicates a server boot when set */ | |
57 | int ncl = 0; | |
58 | ||
59 | vm_map_t buffer_map; | |
60 | vm_map_t bufferhdr_map; | |
61 | ||
62 | void | |
63 | bsd_startupearly() | |
64 | { | |
65 | vm_offset_t firstaddr; | |
66 | vm_size_t size; | |
67 | kern_return_t ret; | |
68 | ||
69 | if (nbuf == 0) | |
70 | nbuf = atop(mem_size / 100); /* 1% */ | |
71 | if (nbuf > 8192) | |
72 | nbuf = 8192; | |
73 | if (nbuf < 256) | |
74 | nbuf = 256; | |
75 | ||
76 | if (niobuf == 0) | |
9bccf70c | 77 | niobuf = (nbuf / 2) + 64; /* 64 reserved buffers */ |
1c79356b A |
78 | if (niobuf > 4096) |
79 | niobuf = 4096; | |
80 | if (niobuf < 128) | |
81 | niobuf = 128; | |
82 | ||
83 | size = (nbuf + niobuf) * sizeof (struct buf); | |
84 | size = round_page(size); | |
85 | ||
86 | ret = kmem_suballoc(kernel_map, | |
87 | &firstaddr, | |
88 | size, | |
89 | FALSE, | |
90 | TRUE, | |
91 | &bufferhdr_map); | |
92 | ||
93 | if (ret != KERN_SUCCESS) | |
94 | panic("Failed to create bufferhdr_map"); | |
95 | ||
96 | ret = kernel_memory_allocate(bufferhdr_map, | |
97 | &firstaddr, | |
98 | size, | |
99 | 0, | |
100 | KMA_HERE | KMA_KOBJECT); | |
101 | ||
102 | if (ret != KERN_SUCCESS) | |
103 | panic("Failed to allocate bufferhdr_map"); | |
104 | ||
105 | buf = (struct buf * )firstaddr; | |
106 | bzero(buf,size); | |
107 | ||
108 | if (mem_size > (64 * 1024 * 1024)) { | |
109 | int scale; | |
110 | extern u_long tcp_sendspace; | |
111 | extern u_long tcp_recvspace; | |
112 | ||
113 | if ((nmbclusters = ncl) == 0) { | |
9bccf70c A |
114 | if ((nmbclusters = ((mem_size / 16) / MCLBYTES)) > 16384) |
115 | nmbclusters = 16384; | |
1c79356b A |
116 | } |
117 | if ((scale = nmbclusters / NMBCLUSTERS) > 1) { | |
118 | tcp_sendspace *= scale; | |
119 | tcp_recvspace *= scale; | |
120 | ||
121 | if (tcp_sendspace > (32 * 1024)) | |
122 | tcp_sendspace = 32 * 1024; | |
123 | if (tcp_recvspace > (32 * 1024)) | |
124 | tcp_recvspace = 32 * 1024; | |
125 | } | |
126 | } | |
127 | } | |
128 | ||
129 | void | |
130 | bsd_bufferinit() | |
131 | { | |
132 | unsigned int i; | |
133 | vm_size_t size; | |
134 | kern_return_t ret; | |
135 | vm_offset_t firstaddr; | |
136 | ||
137 | cons.t_dev = makedev(12, 0); | |
138 | ||
139 | bsd_startupearly(); | |
140 | ||
141 | ret = kmem_suballoc(kernel_map, | |
142 | (vm_offset_t *)&mbutl, | |
143 | (vm_size_t) (nmbclusters * MCLBYTES), | |
144 | FALSE, | |
145 | TRUE, | |
146 | &mb_map); | |
147 | ||
148 | if (ret != KERN_SUCCESS) | |
149 | panic("Failed to allocate mb_map\n"); | |
150 | ||
151 | /* | |
152 | * Set up buffers, so they can be used to read disk labels. | |
153 | */ | |
154 | bufinit(); | |
155 | } | |
156 | ||
0b4e3aa0 A |
157 | void |
158 | md_prepare_for_shutdown(int paniced, int howto, char * command) | |
159 | { | |
160 | } |