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