]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/i386/i386_init.c
xnu-792.tar.gz
[apple/xnu.git] / osfmk / i386 / i386_init.c
index c0343c5252a13e06b9309c8b93b15b2d8d209e4a..78d4cef000eef76f4f5d29a7422f23b49763231f 100644 (file)
  * the rights to redistribute these changes.
  */
 
-#include <cpus.h>
 #include <platforms.h>
 #include <mach_kdb.h>
 #include <himem.h>
-#include <fast_idle.h>
 
 #include <mach/i386/vm_param.h>
 
 #include <mach/vm_prot.h>
 #include <mach/machine.h>
 #include <mach/time_value.h>
-#include <kern/etap_macros.h>
 #include <kern/spl.h>
 #include <kern/assert.h>
 #include <kern/debug.h>
 #include <kern/misc_protos.h>
 #include <kern/startup.h>
 #include <kern/clock.h>
-#include <kern/time_out.h>
 #include <kern/xpr.h>
 #include <kern/cpu_data.h>
 #include <kern/processor.h>
 #include <i386/pio.h>
 #include <i386/misc_protos.h>
 #include <i386/cpuid.h>
-#include <i386/rtclock_entries.h>
 #include <i386/mp.h>
+#include <i386/machine_routines.h>
+#include <i386/postcode.h>
 #if    MACH_KDB
 #include <ddb/db_aout.h>
 #endif /* MACH_KDB */
 #include <ddb/tr.h>
 #ifdef __MACHO__
-#include <mach/boot_info.h>
 #include <mach/thread_status.h>
 
 static KernelBootArgs_t *kernelBootArgs;
@@ -100,32 +96,45 @@ vm_offset_t        boot_args_start = 0;    /* pointer to kernel arguments, set in start.s
 #include       <mach-o/loader.h>
 vm_offset_t     edata, etext, end;
 
+/* operations only against currently loaded 32 bit mach kernel */
+extern struct segment_command *getsegbyname(const char *);
+extern struct section *firstsect(struct segment_command *);
+extern struct section *nextsect(struct segment_command *, struct section *);
+
 /*
  * Called first for a mach-o kernel before paging is set up.
  * Returns the first available physical address in memory.
  */
 
-unsigned long
-i386_preinit()
+void
+i386_preinit(void)
 {
        struct segment_command  *sgp;
        struct section          *sp;
+       struct KernelBootArgs *pp;
+       int i;
 
-       sgp = (struct segment_command *) getsegbyname("__DATA");
+       sgp = getsegbyname("__DATA");
        if (sgp) {
-               sp = (struct section *) firstsect(sgp);
+               sp = firstsect(sgp);
                if (sp) {
                        do {
-                               if (sp->flags & S_ZEROFILL)
+                               if ((sp->flags & S_ZEROFILL))
                                        bzero((char *) sp->addr, sp->size);
-                       } while (sp = (struct section *)nextsect(sgp, sp));
+                       } while ((sp = nextsect(sgp, sp)));
                }
        }
 
-       kernelBootArgs = (KernelBootArgs_t *) boot_args_start;
-       end = round_page( kernelBootArgs->kaddr + kernelBootArgs->ksize );
-
-       return  end;
+       kernelBootArgs = (KernelBootArgs_t *)
+               ml_static_ptovirt(boot_args_start);
+       pp = (struct KernelBootArgs *) kernelBootArgs;
+       pp->configEnd = (char *)
+               ml_static_ptovirt((vm_offset_t) pp->configEnd);
+       for (i = 0; i < pp->numBootDrivers; i++) {
+               pp->driverConfig[i].address = (unsigned)
+                       ml_static_ptovirt(pp->driverConfig[i].address);
+       }
+       return;
 }
 #endif
 
@@ -140,30 +149,35 @@ void
 i386_init(void)
 {
        unsigned int    maxmem;
+       unsigned int    cpus;
+
+       postcode(I386_INIT_ENTRY);
 
+       master_cpu = 0;
+       cpu_data_alloc(TRUE);
        cpu_init();
+       postcode(CPU_INIT_D);
 
        /*
         * Setup some processor related structures to satisfy funnels.
         * Must be done before using unparallelized device drivers.
         */
-       processor_ptr[0] = &processor_array[0];
-       master_cpu = 0;
-       master_processor = cpu_to_processor(master_cpu);
+       processor_bootstrap();
 
        PE_init_platform(FALSE, kernelBootArgs);
+       postcode(PE_INIT_PLATFORM_D);
 
        /*
         * Set up initial thread so current_thread() works early on
         */
        thread_bootstrap();
+       postcode(THREAD_BOOTSTRAP_D);
 
        printf_init();                  /* Init this in case we need debugger */
        panic_init();                   /* Init this in case we need debugger */
 
        /* setup debugging output if one has been chosen */
        PE_init_kprintf(FALSE);
-       kprintf("kprintf initialized\n");
 
        /* setup console output */
        PE_init_printf(FALSE);
@@ -171,7 +185,6 @@ i386_init(void)
        kprintf("version_variant = %s\n", version_variant);
        kprintf("version         = %s\n", version);
 
-
        /*   
         * VM initialization, after this we're using page tables...
         * The maximum number of cpus must be set beforehand.
@@ -181,11 +194,10 @@ i386_init(void)
        else
                maxmem = maxmem * (1024 * 1024);
 
-       if (PE_parse_boot_arg("cpus", &wncpu)) {
-               if (!((wncpu > 0) && (wncpu < NCPUS)))
-                        wncpu = NCPUS;
-       } else 
-               wncpu = NCPUS;
+       if (PE_parse_boot_arg("cpus", &cpus)) {
+               if ((0 < cpus) && (cpus < max_ncpus))
+                        max_ncpus = cpus;
+       }
 
        i386_vm_init(maxmem, kernelBootArgs);
 
@@ -193,7 +205,7 @@ i386_init(void)
 
        /* create the console for verbose or pretty mode */
        PE_create_console();
-       
+
        machine_startup();
 
 }