]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/ppc/ppc_vm_init.c
xnu-1228.tar.gz
[apple/xnu.git] / osfmk / ppc / ppc_vm_init.c
index 61fa389aa33d7f2078e6acdc6dc5ab5dc5e9965f..af15986864de23ae89d0d150b51e3256e6671e6c 100644 (file)
@@ -1,14 +1,19 @@
 /*
- * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
  *
- * @APPLE_LICENSE_HEADER_START@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
  * This file contains Original Code and/or Modifications of Original Code
  * as defined in and that are subject to the Apple Public Source License
  * Version 2.0 (the 'License'). You may not use this file except in
- * compliance with the License. Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this
- * file.
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
+ * 
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
  * 
  * The Original Code and all software distributed under the License are
  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
@@ -18,7 +23,7 @@
  * Please see the License for the specific language governing rights and
  * limitations under the License.
  * 
- * @APPLE_LICENSE_HEADER_END@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
  */
 /*
  * @OSF_COPYRIGHT@
@@ -39,6 +44,7 @@
 #include <kern/assert.h>
 #include <kern/cpu_number.h>
 #include <kern/thread.h>
+#include <console/serial_protos.h>
 
 #include <ppc/proc_reg.h>
 #include <ppc/Firmware.h>
@@ -49,6 +55,7 @@
 #include <ppc/mappings.h>
 #include <ppc/exception.h>
 #include <ppc/lowglobals.h>
+#include <ppc/serial_io.h>
 
 #include <mach-o/mach_header.h>
 
@@ -60,7 +67,6 @@ unsigned int hash_table_size;                 /* Hash table size */
 int         hash_table_shift;           /* "ht_shift" boot arg, used to scale hash_table_size */
 vm_offset_t taproot_addr;                              /* (BRINGUP) */
 unsigned int taproot_size;                             /* (BRINGUP) */
-unsigned int serialmode;                               /* Serial mode keyboard and console control */
 extern int disableConsoleOutput;
 
 struct shadowBAT shadow_BAT;
@@ -81,7 +87,7 @@ uint64_t      sane_size;                                      /* Memory size to use for defaults calculations */
                                                  
 
 mem_region_t pmap_mem_regions[PMAP_MEM_REGION_MAX + 1];
-int     pmap_mem_regions_count = 0;            /* Assume no non-contiguous memory regions */
+unsigned int  pmap_mem_regions_count;          /* Assume no non-contiguous memory regions */
 
 unsigned int avail_remaining = 0;
 vm_offset_t first_avail;
@@ -202,21 +208,22 @@ void ppc_vm_init(uint64_t mem_limit, boot_args *args)
 
        first_avail = static_memory_end;
 
-/*
- * Now retrieve addresses for end, edata, and etext 
- * from MACH-O headers for the currently running 32 bit kernel.
- */
-       sectTEXTB = (vm_offset_t)getsegdatafromheader(
+       /*
+        * Now retrieve addresses for end, edata, and etext 
+        * from MACH-O headers for the currently running 32 bit kernel.
+        */
+       /* XXX fix double casts for 64 bit kernel */
+       sectTEXTB = (vm_offset_t)(uint32_t *)getsegdatafromheader(
                &_mh_execute_header, "__TEXT", &sectSizeTEXT);
-       sectDATAB = (vm_offset_t)getsegdatafromheader(
+       sectDATAB = (vm_offset_t)(uint32_t *)getsegdatafromheader(
                &_mh_execute_header, "__DATA", &sectSizeDATA);
-       sectLINKB = (vm_offset_t)getsegdatafromheader(
+       sectLINKB = (vm_offset_t)(uint32_t *)getsegdatafromheader(
                &_mh_execute_header, "__LINKEDIT", &sectSizeLINK);
-       sectKLDB = (vm_offset_t)getsegdatafromheader(
+       sectKLDB = (vm_offset_t)(uint32_t *)getsegdatafromheader(
                &_mh_execute_header, "__KLD", &sectSizeKLD);
-       sectHIBB = (vm_offset_t)getsegdatafromheader(
+       sectHIBB = (vm_offset_t)(uint32_t *)getsegdatafromheader(
                &_mh_execute_header, "__HIB", &sectSizeHIB);
-       sectPRELINKB = (vm_offset_t)getsegdatafromheader(
+       sectPRELINKB = (vm_offset_t)(uint32_t *)getsegdatafromheader(
                &_mh_execute_header, "__PRELINK", &sectSizePRELINK);
 
        etext = (vm_offset_t) sectTEXTB + sectSizeTEXT;
@@ -235,13 +242,13 @@ void ppc_vm_init(uint64_t mem_limit, boot_args *args)
        pmap_bootstrap(max_mem, &first_avail, kmapsize);
 
        pmap_map(trunc_page(exception_entry), trunc_page(exception_entry), 
-               round_page(exception_end), VM_PROT_READ|VM_PROT_EXECUTE);
+               round_page(exception_end), VM_PROT_READ|VM_PROT_EXECUTE, VM_WIMG_USE_DEFAULT);
 
        pmap_map(trunc_page(sectTEXTB), trunc_page(sectTEXTB), 
-               round_page(sectTEXTB+sectSizeTEXT), VM_PROT_READ|VM_PROT_EXECUTE);
+               round_page(sectTEXTB+sectSizeTEXT), VM_PROT_READ|VM_PROT_EXECUTE, VM_WIMG_USE_DEFAULT);
 
        pmap_map(trunc_page(sectDATAB), trunc_page(sectDATAB), 
-               round_page(sectDATAB+sectSizeDATA), VM_PROT_READ|VM_PROT_WRITE);
+               round_page(sectDATAB+sectSizeDATA), VM_PROT_READ|VM_PROT_WRITE, VM_WIMG_USE_DEFAULT);
 
 /* The KLD and LINKEDIT segments are unloaded in toto after boot completes,
 * but via ml_static_mfree(), through IODTFreeLoaderInfo(). Hence, we have
@@ -253,7 +260,7 @@ void ppc_vm_init(uint64_t mem_limit, boot_args *args)
              addr += PAGE_SIZE) {
 
             pmap_enter(kernel_pmap, (vm_map_offset_t)addr, (ppnum_t)(addr>>12), 
-                       VM_PROT_READ|VM_PROT_WRITE, 
+                       VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE
                        VM_WIMG_USE_DEFAULT, TRUE);
 
        }
@@ -263,7 +270,7 @@ void ppc_vm_init(uint64_t mem_limit, boot_args *args)
              addr += PAGE_SIZE) {
 
             pmap_enter(kernel_pmap, (vm_map_offset_t)addr, (ppnum_t)(addr>>12), 
-                       VM_PROT_READ|VM_PROT_WRITE, 
+                       VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE
                        VM_WIMG_USE_DEFAULT, TRUE);
 
        }
@@ -274,7 +281,7 @@ void ppc_vm_init(uint64_t mem_limit, boot_args *args)
 
            pmap_enter(kernel_pmap, (vm_map_offset_t)addr,
                        (ppnum_t)(addr>>12), 
-                       VM_PROT_READ|VM_PROT_WRITE, 
+                       VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE
                        VM_WIMG_USE_DEFAULT, TRUE);
 
        }
@@ -284,7 +291,7 @@ void ppc_vm_init(uint64_t mem_limit, boot_args *args)
              addr += PAGE_SIZE) {
 
             pmap_enter(kernel_pmap, (vm_map_offset_t)addr, (ppnum_t)(addr>>12), 
-                       VM_PROT_READ|VM_PROT_WRITE, 
+                       VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE
                        VM_WIMG_USE_DEFAULT, TRUE);
 
        }
@@ -307,7 +314,7 @@ void ppc_vm_init(uint64_t mem_limit, boot_args *args)
        for(addr = trunc_page(end); addr < round_page(static_memory_end); addr += PAGE_SIZE) {
 
                pmap_enter(kernel_pmap, (vm_map_address_t)addr, (ppnum_t)addr>>12, 
-                       VM_PROT_READ|VM_PROT_WRITE, 
+                       VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE
                        VM_WIMG_USE_DEFAULT, TRUE);
 
        }
@@ -370,7 +377,7 @@ void ppc_vm_init(uint64_t mem_limit, boot_args *args)
        taproot_size = PE_init_taproot(&taproot_addr);  /* (BRINGUP) See if there is a taproot */
        if(taproot_size) {                                      /* (BRINGUP) */
                kprintf("TapRoot card configured to use vaddr = %08X, size = %08X\n", taproot_addr, taproot_size);
-               bcopy_nc((void *)version, (void *)(taproot_addr + 16), strlen(version));        /* (BRINGUP) Pass it our kernel version */
+               bcopy_nc(version, (void *)(taproot_addr + 16), strlen(version));        /* (BRINGUP) Pass it our kernel version */
                __asm__ volatile("eieio");              /* (BRINGUP) */
                xtaproot = (unsigned int *)taproot_addr;        /* (BRINGUP) */
                xtaproot[0] = 1;                                /* (BRINGUP) */
@@ -388,15 +395,12 @@ void ppc_vm_init(uint64_t mem_limit, boot_args *args)
 
 
        /* Processor version information */
-       {       
-               unsigned int pvr;
-               __asm__ ("mfpvr %0" : "=r" (pvr));
-               printf("processor version register : %08X\n", pvr);
-       }
+       __asm__ ("mfpvr %0" : "=r" (pvr));
+       printf("processor version register : %08X\n", pvr);
 
-       kprintf("Args at %08X\n", args);
+       kprintf("Args at %p\n", args);
        for (i = 0; i < pmap_mem_regions_count; i++) {
-                       printf("DRAM at %08X size %08X\n",
+                       printf("DRAM at %08lX size %08lX\n",
                               args->PhysicalDRAM[i].base,
                               args->PhysicalDRAM[i].size);
        }