]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/kern/bsd_init.c
xnu-2050.18.24.tar.gz
[apple/xnu.git] / bsd / kern / bsd_init.c
index dac2c94d899c0657f23ed7b5f2a30481568b2238..2a04fff666c295224998cc861ac1062a30a5828e 100644 (file)
 #include <sys/mcache.h>                        /* for mcache_init() */
 #include <sys/mbuf.h>                  /* for mbinit() */
 #include <sys/event.h>                 /* for knote_init() */
 #include <sys/mcache.h>                        /* for mcache_init() */
 #include <sys/mbuf.h>                  /* for mbinit() */
 #include <sys/event.h>                 /* for knote_init() */
-#include <sys/kern_memorystatus.h>     /* for kern_memorystatus_init() */
+#include <sys/kern_memorystatus.h>     /* for memorystatus_init() */
 #include <sys/aio_kern.h>              /* for aio_init() */
 #include <sys/semaphore.h>             /* for psem_cache_init() */
 #include <net/dlil.h>                  /* for dlil_init() */
 #include <net/kpi_protocol.h>          /* for proto_kpi_init() */
 #include <sys/aio_kern.h>              /* for aio_init() */
 #include <sys/semaphore.h>             /* for psem_cache_init() */
 #include <net/dlil.h>                  /* for dlil_init() */
 #include <net/kpi_protocol.h>          /* for proto_kpi_init() */
+#include <net/iptap.h>                 /* for iptap_init() */
 #include <sys/pipe.h>                  /* for pipeinit() */
 #include <sys/socketvar.h>             /* for socketinit() */
 #include <sys/protosw.h>               /* for domaininit() */
 #include <sys/pipe.h>                  /* for pipeinit() */
 #include <sys/socketvar.h>             /* for socketinit() */
 #include <sys/protosw.h>               /* for domaininit() */
 #include <net/if_utun.h>               /* for utun_register_control() */
 #include <net/net_str_id.h>            /* for net_str_id_init() */
 #include <net/netsrc.h>                        /* for netsrc_init() */
 #include <net/if_utun.h>               /* for utun_register_control() */
 #include <net/net_str_id.h>            /* for net_str_id_init() */
 #include <net/netsrc.h>                        /* for netsrc_init() */
+#include <net/ntstat.h>                        /* for nstat_init() */
 #include <kern/assert.h>               /* for assert() */
 
 #include <net/init.h>
 #include <kern/assert.h>               /* for assert() */
 
 #include <net/init.h>
 
 #include <pexpert/pexpert.h>
 #include <machine/pal_routines.h>
 
 #include <pexpert/pexpert.h>
 #include <machine/pal_routines.h>
+#include <console/video_console.h>
 
 void * get_user_regs(thread_t);                /* XXX kludge for <machine/thread.h> */
 void IOKitInitializeTime(void);                /* XXX */
 void IOSleep(unsigned int);            /* XXX */
 void loopattach(void);                 /* XXX */
 
 void * get_user_regs(thread_t);                /* XXX kludge for <machine/thread.h> */
 void IOKitInitializeTime(void);                /* XXX */
 void IOSleep(unsigned int);            /* XXX */
 void loopattach(void);                 /* XXX */
-void vc_progress_set(boolean_t, uint32_t); /* XXX */
 
 const char    copyright[] =
 "Copyright (c) 1982, 1986, 1989, 1991, 1993\n\t"
 
 const char    copyright[] =
 "Copyright (c) 1982, 1986, 1989, 1991, 1993\n\t"
@@ -223,13 +225,6 @@ char       hostname[MAXHOSTNAMELEN];
 int            hostnamelen;
 char   domainname[MAXDOMNAMELEN];
 int            domainnamelen;
 int            hostnamelen;
 char   domainname[MAXDOMNAMELEN];
 int            domainnamelen;
-#if defined(__i386__) || defined(__x86_64__)
-struct exec_archhandler exec_archhandler_ppc = {
-       .path = "/usr/libexec/oah/RosettaNonGrata",
-};
-#else /* __i386__ */
-struct exec_archhandler exec_archhandler_ppc;
-#endif /* __i386__ */
 
 char rootdevice[16];   /* hfs device names have at least 9 chars */
 
 
 char rootdevice[16];   /* hfs device names have at least 9 chars */
 
@@ -250,6 +245,7 @@ extern void klogwakeup(void);
 extern void file_lock_init(void);
 extern void kmeminit(void);
 extern void bsd_bufferinit(void);
 extern void file_lock_init(void);
 extern void kmeminit(void);
 extern void bsd_bufferinit(void);
+extern void throttle_init(void);
 
 extern int serverperfmode;
 extern int ncl;
 
 extern int serverperfmode;
 extern int ncl;
@@ -263,13 +259,8 @@ __private_extern__ int execargs_cache_size = 0;
 __private_extern__ int execargs_free_count = 0;
 __private_extern__ vm_offset_t * execargs_cache = NULL;
 
 __private_extern__ int execargs_free_count = 0;
 __private_extern__ vm_offset_t * execargs_cache = NULL;
 
-void bsd_exec_setup(int);
+void bsd_exec_setup(int) __attribute__((aligned(4096)));
 
 
-/*
- * Set to disable grading 64 bit Mach-o binaries as executable, for testing;
- * Intel only.
- */
-__private_extern__ int bootarg_no64exec = 0;
 __private_extern__ int bootarg_vnode_cache_defeat = 0;
 
 /*
 __private_extern__ int bootarg_vnode_cache_defeat = 0;
 
 /*
@@ -330,7 +321,6 @@ extern void stackshot_lock_init(void);
        extern void dtrace_postinit(void);
 #endif
 
        extern void dtrace_postinit(void);
 #endif
 
-
 /*
  * Initialization code.
  * Called from cold start routine as
 /*
  * Initialization code.
  * Called from cold start routine as
@@ -394,14 +384,15 @@ void (*unmountroot_pre_hook)(void);
  * of the uu_context.vc_ucred field so that the uthread structure can be
  * used like any other.
  */
  * of the uu_context.vc_ucred field so that the uthread structure can be
  * used like any other.
  */
+extern void run_bringup_tests(void);
+
+extern void IOServicePublishResource(const char *, boolean_t);
+
 void
 bsd_init(void)
 {
        struct uthread *ut;
        unsigned int i;
 void
 bsd_init(void)
 {
        struct uthread *ut;
        unsigned int i;
-#if __i386__ || __x86_64__
-       int error;
-#endif 
        struct vfs_context context;
        kern_return_t   ret;
        struct ucred temp_cred;
        struct vfs_context context;
        kern_return_t   ret;
        struct ucred temp_cred;
@@ -412,6 +403,8 @@ bsd_init(void)
 
 #define bsd_init_kprintf(x...) /* kprintf("bsd_init: " x) */
 
 
 #define bsd_init_kprintf(x...) /* kprintf("bsd_init: " x) */
 
+       throttle_init();
+
        kernel_flock = funnel_alloc(KERNEL_FUNNEL);
        if (kernel_flock == (funnel_t *)0 ) {
                panic("bsd_init: Failed to allocate kernel funnel");
        kernel_flock = funnel_alloc(KERNEL_FUNNEL);
        if (kernel_flock == (funnel_t *)0 ) {
                panic("bsd_init: Failed to allocate kernel funnel");
@@ -775,22 +768,26 @@ bsd_init(void)
        socketinit();
        bsd_init_kprintf("calling domaininit\n");
        domaininit();
        socketinit();
        bsd_init_kprintf("calling domaininit\n");
        domaininit();
+       iptap_init();
 #endif /* SOCKETS */
 
        kernproc->p_fd->fd_cdir = NULL;
        kernproc->p_fd->fd_rdir = NULL;
 
 #if CONFIG_FREEZE
 #endif /* SOCKETS */
 
        kernproc->p_fd->fd_cdir = NULL;
        kernproc->p_fd->fd_rdir = NULL;
 
 #if CONFIG_FREEZE
-       /* Initialise background hibernation */
-       bsd_init_kprintf("calling kern_hibernation_init\n");
-       kern_hibernation_init();
+#ifndef CONFIG_MEMORYSTATUS
+    #error "CONFIG_FREEZE defined without matching CONFIG_MEMORYSTATUS"
+#endif
+       /* Initialise background freezing */
+       bsd_init_kprintf("calling memorystatus_freeze_init\n");
+       memorystatus_freeze_init();
 #endif
 
 #endif
 
-#if CONFIG_EMBEDDED
+#if CONFIG_MEMORYSTATUS
        /* Initialize kernel memory status notifications */
        /* Initialize kernel memory status notifications */
-       bsd_init_kprintf("calling kern_memorystatus_init\n");
-       kern_memorystatus_init();
-#endif
+       bsd_init_kprintf("calling memorystatus_init\n");
+       memorystatus_init();
+#endif /* CONFIG_MEMORYSTATUS */
 
 #ifdef GPROF
        /* Initialize kernel profiling. */
 
 #ifdef GPROF
        /* Initialize kernel profiling. */
@@ -837,10 +834,8 @@ bsd_init(void)
        
        /* register user tunnel kernel control handler */
        utun_register_control();
        
        /* register user tunnel kernel control handler */
        utun_register_control();
-    netsrc_init();
-       
-       /* wait for network domain to finish */
-       domainfin();
+       netsrc_init();
+       nstat_init();
 #endif /* NETWORKING */
 
        bsd_init_kprintf("calling vnode_pager_bootstrap\n");
 #endif /* NETWORKING */
 
        bsd_init_kprintf("calling vnode_pager_bootstrap\n");
@@ -963,13 +958,6 @@ bsd_init(void)
 
        pal_kernel_announce();
 
 
        pal_kernel_announce();
 
-#if __i386__ || __x86_64__
-       /* this should be done after the root filesystem is mounted */
-       error = set_archhandler(kernproc, CPU_TYPE_POWERPC);
-       if (error) /* XXX make more generic */
-               exec_archhandler_ppc.path[0] = 0;
-#endif 
-
        bsd_init_kprintf("calling mountroot_post_hook\n");
 
        /* invoke post-root-mount hook */
        bsd_init_kprintf("calling mountroot_post_hook\n");
 
        /* invoke post-root-mount hook */
@@ -1131,10 +1119,6 @@ parse_bsd_args(void)
        if (PE_parse_boot_argn("-x", namep, sizeof (namep))) /* safe boot */
                boothowto |= RB_SAFEBOOT;
 
        if (PE_parse_boot_argn("-x", namep, sizeof (namep))) /* safe boot */
                boothowto |= RB_SAFEBOOT;
 
-       /* disable 64 bit grading */
-       if (PE_parse_boot_argn("-no64exec", namep, sizeof (namep)))
-               bootarg_no64exec = 1;
-
        /* disable vnode_cache_is_authorized() by setting vnode_cache_defeat */
        if (PE_parse_boot_argn("-vnode_cache_defeat", namep, sizeof (namep)))
                bootarg_vnode_cache_defeat = 1;
        /* disable vnode_cache_is_authorized() by setting vnode_cache_defeat */
        if (PE_parse_boot_argn("-vnode_cache_defeat", namep, sizeof (namep)))
                bootarg_vnode_cache_defeat = 1;