Sun Mar 15 19:43:49 2009 UTC ()
Pull up following revision(s) (requested by christos in ticket #458):
	sys/conf/Makefile.kern.inc: revision 1.121
	sys/conf/files: revision 1.940
	sys/kern/init_main.c: revision 1.381
	sys/kern/kern_ssp.c: revision 1.1
	sys/kern/subr_autoconf.c: revision 1.168
	sys/sys/device.h: revision 1.116
	sys/sys/systm.h: revision 1.233
Unbreak ssp kernels. The issue here that when the ssp_init() call was
deferred, it caused the return from the enclosing function to break, as
well as the ssp return on i386. To fix both issues, split configure in
two pieces the one before calling ssp_init and the one after, and move
the ssp_init() call back in main. Put ssp_init() in its own file, and
compile this new file with -fno-stack-protector. Tested on amd64.
XXX: If we want to have ssp kernels working on 5.0, this change needs to
be pulled up.


(snj)
diff -r1.118 -r1.118.4.1 src/sys/conf/Makefile.kern.inc
diff -r1.924 -r1.924.4.1 src/sys/conf/files
diff -r1.371 -r1.371.2.1 src/sys/kern/init_main.c
diff -r0 -r1.2.4.2 src/sys/kern/kern_ssp.c
diff -r1.163.4.1 -r1.163.4.2 src/sys/kern/subr_autoconf.c
diff -r1.112 -r1.112.6.1 src/sys/sys/device.h
diff -r1.228.4.1 -r1.228.4.2 src/sys/sys/systm.h

cvs diff -r1.118 -r1.118.4.1 src/sys/conf/Makefile.kern.inc (expand / switch to unified diff)

--- src/sys/conf/Makefile.kern.inc 2008/10/25 22:27:38 1.118
+++ src/sys/conf/Makefile.kern.inc 2009/03/15 19:43:48 1.118.4.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: Makefile.kern.inc,v 1.118 2008/10/25 22:27:38 apb Exp $ 1# $NetBSD: Makefile.kern.inc,v 1.118.4.1 2009/03/15 19:43:48 snj Exp $
2# 2#
3# This file contains common `MI' targets and definitions and it is included 3# This file contains common `MI' targets and definitions and it is included
4# at the bottom of each `MD' ${MACHINE}/conf/Makefile.${MACHINE}. 4# at the bottom of each `MD' ${MACHINE}/conf/Makefile.${MACHINE}.
5# 5#
6# Each target in this file should be protected with `if !target(target)' 6# Each target in this file should be protected with `if !target(target)'
7# or `if !commands(target)' and each variable should only be conditionally 7# or `if !commands(target)' and each variable should only be conditionally
8# assigned `VAR ?= VALUE', so that everything can be overriden. 8# assigned `VAR ?= VALUE', so that everything can be overriden.
9# 9#
10# DEBUG is set to -g if debugging. 10# DEBUG is set to -g if debugging.
11# PROF is set to -pg if profiling. 11# PROF is set to -pg if profiling.
12# 12#
13# To specify debugging, add the config line: makeoptions DEBUG="-g" 13# To specify debugging, add the config line: makeoptions DEBUG="-g"
14# A better way is to specify -g only for a few files. 14# A better way is to specify -g only for a few files.
@@ -85,26 +85,27 @@ CWARNFLAGS+= -Wextra -Wno-unused-paramet @@ -85,26 +85,27 @@ CWARNFLAGS+= -Wextra -Wno-unused-paramet
85 85
86CFLAGS+= -ffreestanding -fno-zero-initialized-in-bss 86CFLAGS+= -ffreestanding -fno-zero-initialized-in-bss
87CFLAGS+= ${DEBUG} ${COPTS} 87CFLAGS+= ${DEBUG} ${COPTS}
88AFLAGS+= -D_LOCORE -Wa,-fatal-warnings 88AFLAGS+= -D_LOCORE -Wa,-fatal-warnings
89 89
90# XXX 90# XXX
91.if defined(HAVE_GCC) && ${HAVE_GCC} > 3 91.if defined(HAVE_GCC) && ${HAVE_GCC} > 3
92CFLAGS+= -fno-strict-aliasing 92CFLAGS+= -fno-strict-aliasing
93.endif 93.endif
94 94
95.if ${USE_SSP:Uno} == "yes" 95.if ${USE_SSP:Uno} == "yes"
96CFLAGS+=-fstack-protector -Wstack-protector --param ssp-buffer-size=1 96CFLAGS+=-fstack-protector -Wstack-protector --param ssp-buffer-size=1
97LDFLAGS+=-fstack-protector -Wstack-protector --param ssp-buffer-size=1 97LDFLAGS+=-fstack-protector -Wstack-protector --param ssp-buffer-size=1
 98COPTS.kern_ssp.c+= -fno-stack-protector -D__SSP__
98.endif 99.endif
99 100
100# If we want the bpendtsleep: label in kern_synch.c, we need to use 101# If we want the bpendtsleep: label in kern_synch.c, we need to use
101# -fno-reorder-blocks. Don't make this a config(1) defflag without 102# -fno-reorder-blocks. Don't make this a config(1) defflag without
102# making sure this fragment remains valid. 103# making sure this fragment remains valid.
103.if defined(HAVE_GCC) && ${HAVE_GCC} > 3 && \ 104.if defined(HAVE_GCC) && ${HAVE_GCC} > 3 && \
104 !empty(${CFLAGS:M-DKERN_SYNCH_BPENDTSLEEP_LABEL}) 105 !empty(${CFLAGS:M-DKERN_SYNCH_BPENDTSLEEP_LABEL})
105COPTS.kern_synch.c+= -fno-reorder-blocks 106COPTS.kern_synch.c+= -fno-reorder-blocks
106.endif 107.endif
107 108
108# Use the per-source COPTS variables to add -g to just those 109# Use the per-source COPTS variables to add -g to just those
109# files that match the shell patterns given in ${DEBUGLIST} 110# files that match the shell patterns given in ${DEBUGLIST}
110# 111#

cvs diff -r1.924 -r1.924.4.1 src/sys/conf/files (expand / switch to unified diff)

--- src/sys/conf/files 2008/10/15 06:51:20 1.924
+++ src/sys/conf/files 2009/03/15 19:43:48 1.924.4.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: files,v 1.924 2008/10/15 06:51:20 wrstuden Exp $ 1# $NetBSD: files,v 1.924.4.1 2009/03/15 19:43:48 snj Exp $
2 2
3# @(#)files.newconf 7.5 (Berkeley) 5/10/93 3# @(#)files.newconf 7.5 (Berkeley) 5/10/93
4 4
5version 20080610 5version 20080610
6 6
7# 7#
8# device classes 8# device classes
9# 9#
10devclass disk 10devclass disk
11devclass tape 11devclass tape
12devclass ifnet 12devclass ifnet
13devclass tty 13devclass tty
14devclass audiodev 14devclass audiodev
@@ -1398,26 +1398,27 @@ file kern/kern_ntptime.c @@ -1398,26 +1398,27 @@ file kern/kern_ntptime.c
1398file kern/kern_pax.c pax_mprotect | pax_segvguard 1398file kern/kern_pax.c pax_mprotect | pax_segvguard
1399file kern/kern_physio.c 1399file kern/kern_physio.c
1400file kern/kern_pmf.c 1400file kern/kern_pmf.c
1401file kern/kern_proc.c 1401file kern/kern_proc.c
1402file kern/kern_prot.c 1402file kern/kern_prot.c
1403file kern/kern_ras.c 1403file kern/kern_ras.c
1404file kern/kern_rate.c 1404file kern/kern_rate.c
1405file kern/kern_resource.c 1405file kern/kern_resource.c
1406file kern/kern_runq.c 1406file kern/kern_runq.c
1407file kern/kern_rwlock.c 1407file kern/kern_rwlock.c
1408file kern/kern_sig.c 1408file kern/kern_sig.c
1409file kern/kern_sleepq.c 1409file kern/kern_sleepq.c
1410file kern/kern_softint.c 1410file kern/kern_softint.c
 1411file kern/kern_ssp.c
1411file kern/kern_stub.c 1412file kern/kern_stub.c
1412file kern/kern_subr.c 1413file kern/kern_subr.c
1413file kern/kern_synch.c 1414file kern/kern_synch.c
1414file kern/kern_sysctl.c 1415file kern/kern_sysctl.c
1415file kern/kern_tc.c 1416file kern/kern_tc.c
1416file kern/kern_time.c 1417file kern/kern_time.c
1417file kern/kern_timeout.c 1418file kern/kern_timeout.c
1418file kern/kern_turnstile.c 1419file kern/kern_turnstile.c
1419file kern/kern_todr.c 1420file kern/kern_todr.c
1420file kern/kern_uidinfo.c 1421file kern/kern_uidinfo.c
1421file kern/kern_uuid.c 1422file kern/kern_uuid.c
1422file kern/kern_xxx.c 1423file kern/kern_xxx.c
1423file kern/kgdb_stub.c kgdb 1424file kern/kgdb_stub.c kgdb

cvs diff -r1.371 -r1.371.2.1 src/sys/kern/init_main.c (expand / switch to unified diff)

--- src/sys/kern/init_main.c 2008/10/28 15:33:10 1.371
+++ src/sys/kern/init_main.c 2009/03/15 19:43:48 1.371.2.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: init_main.c,v 1.371 2008/10/28 15:33:10 tsutsui Exp $ */ 1/* $NetBSD: init_main.c,v 1.371.2.1 2009/03/15 19:43:48 snj Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -87,27 +87,27 @@ @@ -87,27 +87,27 @@
87 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 87 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
88 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 88 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
89 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 89 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
90 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 90 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
91 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 91 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
92 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 92 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
93 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 93 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
94 * SUCH DAMAGE. 94 * SUCH DAMAGE.
95 * 95 *
96 * @(#)init_main.c 8.16 (Berkeley) 5/14/95 96 * @(#)init_main.c 8.16 (Berkeley) 5/14/95
97 */ 97 */
98 98
99#include <sys/cdefs.h> 99#include <sys/cdefs.h>
100__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.371 2008/10/28 15:33:10 tsutsui Exp $"); 100__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.371.2.1 2009/03/15 19:43:48 snj Exp $");
101 101
102#include "opt_ddb.h" 102#include "opt_ddb.h"
103#include "opt_ipsec.h" 103#include "opt_ipsec.h"
104#include "opt_ntp.h" 104#include "opt_ntp.h"
105#include "opt_pipe.h" 105#include "opt_pipe.h"
106#include "opt_posix.h" 106#include "opt_posix.h"
107#include "opt_syscall_debug.h" 107#include "opt_syscall_debug.h"
108#include "opt_sysv.h" 108#include "opt_sysv.h"
109#include "opt_fileassoc.h" 109#include "opt_fileassoc.h"
110#include "opt_ktrace.h" 110#include "opt_ktrace.h"
111#include "opt_pax.h" 111#include "opt_pax.h"
112#include "opt_wapbl.h" 112#include "opt_wapbl.h"
113 113
@@ -242,72 +242,26 @@ struct lwp *curlwp = &lwp0; @@ -242,72 +242,26 @@ struct lwp *curlwp = &lwp0;
242#endif 242#endif
243struct proc *initproc; 243struct proc *initproc;
244 244
245struct vnode *rootvp, *swapdev_vp; 245struct vnode *rootvp, *swapdev_vp;
246int boothowto; 246int boothowto;
247int cold = 1; /* still working on startup */ 247int cold = 1; /* still working on startup */
248struct timeval boottime; /* time at system startup - will only follow settime deltas */ 248struct timeval boottime; /* time at system startup - will only follow settime deltas */
249 249
250int start_init_exec; /* semaphore for start_init() */ 250int start_init_exec; /* semaphore for start_init() */
251 251
252static void check_console(struct lwp *l); 252static void check_console(struct lwp *l);
253static void start_init(void *); 253static void start_init(void *);
254void main(void); 254void main(void);
255void ssp_init(void); 
256 
257#if defined(__SSP__) || defined(__SSP_ALL__) 
258long __stack_chk_guard[8] = {0, 0, 0, 0, 0, 0, 0, 0}; 
259void __stack_chk_fail(void); 
260 
261void 
262__stack_chk_fail(void) 
263{ 
264 panic("stack overflow detected; terminated"); 
265} 
266 
267void 
268ssp_init(void) 
269{ 
270 int s; 
271 
272#ifdef DIAGNOSTIC 
273 printf("Initializing SSP:"); 
274#endif 
275 /* 
276 * We initialize ssp here carefully: 
277 * 1. after we got some entropy 
278 * 2. without calling a function 
279 */ 
280 size_t i; 
281 long guard[__arraycount(__stack_chk_guard)]; 
282 
283 arc4randbytes(guard, sizeof(guard)); 
284 s = splhigh(); 
285 for (i = 0; i < __arraycount(guard); i++) 
286 __stack_chk_guard[i] = guard[i]; 
287 splx(s); 
288#ifdef DIAGNOSTIC 
289 for (i = 0; i < __arraycount(guard); i++) 
290 printf("%lx ", guard[i]); 
291 printf("\n"); 
292#endif 
293} 
294#else 
295void 
296ssp_init(void) 
297{ 
298 
299} 
300#endif 
301 255
302void __secmodel_none(void); 256void __secmodel_none(void);
303__weak_alias(secmodel_start,__secmodel_none); 257__weak_alias(secmodel_start,__secmodel_none);
304void 258void
305__secmodel_none(void) 259__secmodel_none(void)
306{ 260{
307 return; 261 return;
308} 262}
309 263
310/* 264/*
311 * System startup; initialize the world, create process 0, mount root 265 * System startup; initialize the world, create process 0, mount root
312 * filesystem, and fork to create init and pagedaemon. Most of the 266 * filesystem, and fork to create init and pagedaemon. Most of the
313 * hard work is done in the lower-level initialization routines including 267 * hard work is done in the lower-level initialization routines including
@@ -497,26 +451,30 @@ main(void) @@ -497,26 +451,30 @@ main(void)
497 451
498 /* Initialize the buffer cache, part 2. */ 452 /* Initialize the buffer cache, part 2. */
499 bufinit2(); 453 bufinit2();
500 454
501 /* Initialize the disk wedge subsystem. */ 455 /* Initialize the disk wedge subsystem. */
502 dkwedge_init(); 456 dkwedge_init();
503 457
504 /* Initialize interfaces. */ 458 /* Initialize interfaces. */
505 ifinit1(); 459 ifinit1();
506 460
507 /* Configure the system hardware. This will enable interrupts. */ 461 /* Configure the system hardware. This will enable interrupts. */
508 configure(); 462 configure();
509 463
 464 ssp_init();
 465
 466 configure2();
 467
510 ubc_init(); /* must be after autoconfig */ 468 ubc_init(); /* must be after autoconfig */
511 469
512#ifdef SYSVSHM 470#ifdef SYSVSHM
513 /* Initialize System V style shared memory. */ 471 /* Initialize System V style shared memory. */
514 shminit(); 472 shminit();
515#endif 473#endif
516 474
517#ifdef SYSVSEM 475#ifdef SYSVSEM
518 /* Initialize System V style semaphores. */ 476 /* Initialize System V style semaphores. */
519 seminit(); 477 seminit();
520#endif 478#endif
521 479
522#ifdef SYSVMSG 480#ifdef SYSVMSG

File Added: src/sys/kern/kern_ssp.c
/*	$NetBSD: kern_ssp.c,v 1.2.4.2 2009/03/15 19:43:48 snj Exp $	*/

/*-
 * Copyright (c) 2008 The NetBSD Foundation, Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_ssp.c,v 1.2.4.2 2009/03/15 19:43:48 snj Exp $");

#include <sys/systm.h>
#include <sys/intr.h>

#if defined(__SSP__) || defined(__SSP_ALL__)
long __stack_chk_guard[8] = {0, 0, 0, 0, 0, 0, 0, 0};
void __stack_chk_fail(void);

void
__stack_chk_fail(void)
{
	panic("stack overflow detected; terminated");
}

void
ssp_init(void)
{
	int s;

#ifdef DIAGNOSTIC
	printf("Initializing SSP:");
#endif
	/*
	 * We initialize ssp here carefully:
	 *	1. after we got some entropy
	 *	2. without calling a function
	 */
	size_t i;
	long guard[__arraycount(__stack_chk_guard)];

	arc4randbytes(guard, sizeof(guard));
	s = splhigh();
	for (i = 0; i < __arraycount(guard); i++)
		__stack_chk_guard[i] = guard[i];
	splx(s);
#ifdef DIAGNOSTIC
	for (i = 0; i < __arraycount(guard); i++)
		printf("%lx ", guard[i]);
	printf("\n");
#endif
}
#else
void
ssp_init(void)
{
}
#endif

cvs diff -r1.163.4.1 -r1.163.4.2 src/sys/kern/subr_autoconf.c (expand / switch to unified diff)

--- src/sys/kern/subr_autoconf.c 2009/02/02 02:38:32 1.163.4.1
+++ src/sys/kern/subr_autoconf.c 2009/03/15 19:43:48 1.163.4.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: subr_autoconf.c,v 1.163.4.1 2009/02/02 02:38:32 snj Exp $ */ 1/* $NetBSD: subr_autoconf.c,v 1.163.4.2 2009/03/15 19:43:48 snj Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996, 2000 Christopher G. Demetriou 4 * Copyright (c) 1996, 2000 Christopher G. Demetriou
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -67,27 +67,27 @@ @@ -67,27 +67,27 @@
67 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 67 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
68 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 68 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
69 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 69 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
70 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 70 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
71 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 71 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
72 * SUCH DAMAGE. 72 * SUCH DAMAGE.
73 * 73 *
74 * from: Header: subr_autoconf.c,v 1.12 93/02/01 19:31:48 torek Exp (LBL) 74 * from: Header: subr_autoconf.c,v 1.12 93/02/01 19:31:48 torek Exp (LBL)
75 * 75 *
76 * @(#)subr_autoconf.c 8.3 (Berkeley) 5/17/94 76 * @(#)subr_autoconf.c 8.3 (Berkeley) 5/17/94
77 */ 77 */
78 78
79#include <sys/cdefs.h> 79#include <sys/cdefs.h>
80__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.163.4.1 2009/02/02 02:38:32 snj Exp $"); 80__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.163.4.2 2009/03/15 19:43:48 snj Exp $");
81 81
82#include "opt_ddb.h" 82#include "opt_ddb.h"
83#include "drvctl.h" 83#include "drvctl.h"
84 84
85#include <sys/param.h> 85#include <sys/param.h>
86#include <sys/device.h> 86#include <sys/device.h>
87#include <sys/disklabel.h> 87#include <sys/disklabel.h>
88#include <sys/conf.h> 88#include <sys/conf.h>
89#include <sys/kauth.h> 89#include <sys/kauth.h>
90#include <sys/malloc.h> 90#include <sys/malloc.h>
91#include <sys/kmem.h> 91#include <sys/kmem.h>
92#include <sys/systm.h> 92#include <sys/systm.h>
93#include <sys/kernel.h> 93#include <sys/kernel.h>
@@ -401,58 +401,58 @@ config_interrupts_thread(void *cookie) @@ -401,58 +401,58 @@ config_interrupts_thread(void *cookie)
401 (*dc->dc_func)(dc->dc_dev); 401 (*dc->dc_func)(dc->dc_dev);
402 kmem_free(dc, sizeof(*dc)); 402 kmem_free(dc, sizeof(*dc));
403 config_pending_decr(); 403 config_pending_decr();
404 } 404 }
405 kthread_exit(0); 405 kthread_exit(0);
406} 406}
407 407
408/* 408/*
409 * Configure the system's hardware. 409 * Configure the system's hardware.
410 */ 410 */
411void 411void
412configure(void) 412configure(void)
413{ 413{
414 extern void ssp_init(void); 
415 CPU_INFO_ITERATOR cii; 
416 struct cpu_info *ci; 
417 int i, s; 
418 
419 /* Initialize data structures. */ 414 /* Initialize data structures. */
420 config_init(); 415 config_init();
421 pmf_init(); 416 pmf_init();
422#if NDRVCTL > 0 417#if NDRVCTL > 0
423 drvctl_init(); 418 drvctl_init();
424#endif 419#endif
425 420
426#ifdef USERCONF 421#ifdef USERCONF
427 if (boothowto & RB_USERCONF) 422 if (boothowto & RB_USERCONF)
428 user_config(); 423 user_config();
429#endif 424#endif
430 425
431 if ((boothowto & (AB_SILENT|AB_VERBOSE)) == AB_SILENT) { 426 if ((boothowto & (AB_SILENT|AB_VERBOSE)) == AB_SILENT) {
432 config_do_twiddle = 1; 427 config_do_twiddle = 1;
433 printf_nolog("Detecting hardware..."); 428 printf_nolog("Detecting hardware...");
434 } 429 }
435 430
436 /* 431 /*
437 * Do the machine-dependent portion of autoconfiguration. This 432 * Do the machine-dependent portion of autoconfiguration. This
438 * sets the configuration machinery here in motion by "finding" 433 * sets the configuration machinery here in motion by "finding"
439 * the root bus. When this function returns, we expect interrupts 434 * the root bus. When this function returns, we expect interrupts
440 * to be enabled. 435 * to be enabled.
441 */ 436 */
442 cpu_configure(); 437 cpu_configure();
 438}
443 439
444 /* Initialize SSP. */ 440void
445 ssp_init(); 441configure2(void)
 442{
 443 CPU_INFO_ITERATOR cii;
 444 struct cpu_info *ci;
 445 int i, s;
446 446
447 /* 447 /*
448 * Now that we've found all the hardware, start the real time 448 * Now that we've found all the hardware, start the real time
449 * and statistics clocks. 449 * and statistics clocks.
450 */ 450 */
451 initclocks(); 451 initclocks();
452 452
453 cold = 0; /* clocks are running, we're warm now! */ 453 cold = 0; /* clocks are running, we're warm now! */
454 s = splsched(); 454 s = splsched();
455 curcpu()->ci_schedstate.spc_flags |= SPCF_RUNNING; 455 curcpu()->ci_schedstate.spc_flags |= SPCF_RUNNING;
456 splx(s); 456 splx(s);
457 457
458 /* Boot the secondary processors. */ 458 /* Boot the secondary processors. */

cvs diff -r1.112 -r1.112.6.1 src/sys/sys/device.h (expand / switch to unified diff)

--- src/sys/sys/device.h 2008/06/11 15:56:11 1.112
+++ src/sys/sys/device.h 2009/03/15 19:43:48 1.112.6.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: device.h,v 1.112 2008/06/11 15:56:11 drochner Exp $ */ 1/* $NetBSD: device.h,v 1.112.6.1 2009/03/15 19:43:48 snj Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996, 2000 Christopher G. Demetriou 4 * Copyright (c) 1996, 2000 Christopher G. Demetriou
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -384,26 +384,27 @@ struct pdevinit { @@ -384,26 +384,27 @@ struct pdevinit {
384extern struct cfdriverlist allcfdrivers;/* list of all cfdrivers */ 384extern struct cfdriverlist allcfdrivers;/* list of all cfdrivers */
385extern struct devicelist alldevs; /* list of all devices */ 385extern struct devicelist alldevs; /* list of all devices */
386extern struct cftablelist allcftables; /* list of all cfdata tables */ 386extern struct cftablelist allcftables; /* list of all cfdata tables */
387extern device_t booted_device; /* the device we booted from */ 387extern device_t booted_device; /* the device we booted from */
388extern device_t booted_wedge; /* the wedge on that device */ 388extern device_t booted_wedge; /* the wedge on that device */
389extern int booted_partition; /* or the partition on that device */ 389extern int booted_partition; /* or the partition on that device */
390 390
391struct vnode *opendisk(struct device *); 391struct vnode *opendisk(struct device *);
392int config_handle_wedges(struct device *, int); 392int config_handle_wedges(struct device *, int);
393 393
394void config_init(void); 394void config_init(void);
395void drvctl_init(void); 395void drvctl_init(void);
396void configure(void); 396void configure(void);
 397void configure2(void);
397 398
398int config_cfdriver_attach(struct cfdriver *); 399int config_cfdriver_attach(struct cfdriver *);
399int config_cfdriver_detach(struct cfdriver *); 400int config_cfdriver_detach(struct cfdriver *);
400 401
401int config_cfattach_attach(const char *, struct cfattach *); 402int config_cfattach_attach(const char *, struct cfattach *);
402int config_cfattach_detach(const char *, struct cfattach *); 403int config_cfattach_detach(const char *, struct cfattach *);
403 404
404int config_cfdata_attach(cfdata_t, int); 405int config_cfdata_attach(cfdata_t, int);
405int config_cfdata_detach(cfdata_t); 406int config_cfdata_detach(cfdata_t);
406 407
407struct cfdriver *config_cfdriver_lookup(const char *); 408struct cfdriver *config_cfdriver_lookup(const char *);
408struct cfattach *config_cfattach_lookup(const char *, const char *); 409struct cfattach *config_cfattach_lookup(const char *, const char *);
409const struct cfiattrdata *cfiattr_lookup(const char *, const struct cfdriver *); 410const struct cfiattrdata *cfiattr_lookup(const char *, const struct cfdriver *);

cvs diff -r1.228.4.1 -r1.228.4.2 src/sys/sys/systm.h (expand / switch to unified diff)

--- src/sys/sys/systm.h 2009/02/26 20:38:00 1.228.4.1
+++ src/sys/sys/systm.h 2009/03/15 19:43:48 1.228.4.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: systm.h,v 1.228.4.1 2009/02/26 20:38:00 snj Exp $ */ 1/* $NetBSD: systm.h,v 1.228.4.2 2009/03/15 19:43:48 snj Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1982, 1988, 1991, 1993 4 * Copyright (c) 1982, 1988, 1991, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * (c) UNIX System Laboratories, Inc. 6 * (c) UNIX System Laboratories, Inc.
7 * All or some portions of this file are derived from material licensed 7 * All or some portions of this file are derived from material licensed
8 * to the University of California by American Telephone and Telegraph 8 * to the University of California by American Telephone and Telegraph
9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
10 * the permission of UNIX System Laboratories, Inc. 10 * the permission of UNIX System Laboratories, Inc.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
@@ -281,26 +281,28 @@ long fuiword(const void *); @@ -281,26 +281,28 @@ long fuiword(const void *);
281void hardclock(struct clockframe *); 281void hardclock(struct clockframe *);
282void softclock(void *); 282void softclock(void *);
283void statclock(struct clockframe *); 283void statclock(struct clockframe *);
284 284
285#ifdef NTP 285#ifdef NTP
286void ntp_init(void); 286void ntp_init(void);
287#ifdef PPS_SYNC 287#ifdef PPS_SYNC
288void hardpps(struct timespec *, long); 288void hardpps(struct timespec *, long);
289#endif /* PPS_SYNC */ 289#endif /* PPS_SYNC */
290#else 290#else
291void ntp_init(void); /* also provides adjtime() functionality */ 291void ntp_init(void); /* also provides adjtime() functionality */
292#endif /* NTP */ 292#endif /* NTP */
293 293
 294void ssp_init(void);
 295
294void initclocks(void); 296void initclocks(void);
295void inittodr(time_t); 297void inittodr(time_t);
296void resettodr(void); 298void resettodr(void);
297void cpu_initclocks(void); 299void cpu_initclocks(void);
298void setrootfstime(time_t); 300void setrootfstime(time_t);
299 301
300void startprofclock(struct proc *); 302void startprofclock(struct proc *);
301void stopprofclock(struct proc *); 303void stopprofclock(struct proc *);
302void proftick(struct clockframe *); 304void proftick(struct clockframe *);
303void setstatclockrate(int); 305void setstatclockrate(int);
304 306
305/* 307/*
306 * Shutdown hooks. Functions to be run with all interrupts disabled 308 * Shutdown hooks. Functions to be run with all interrupts disabled