]> git.saurik.com Git - apple/xnu.git/blobdiff - pexpert/i386/pe_init.c
xnu-1504.9.37.tar.gz
[apple/xnu.git] / pexpert / i386 / pe_init.c
index 82247037d476c1652d47ae9683a5e9423ca14e4f..5a8fa5eff404a38874ddba79d85b82fcc97574ba 100644 (file)
@@ -1,23 +1,29 @@
 /*
- * Copyright (c) 2000 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@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * 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. 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.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * 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
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
- * @APPLE_LICENSE_HEADER_END@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
  */
 /*
  * file: pe_init.c
@@ -25,6 +31,7 @@
  */
 #include <sys/types.h>
 #include <mach/vm_param.h>
+#include <machine/machine_routines.h>
 #include <pexpert/protos.h>
 #include <pexpert/pexpert.h>
 #include <pexpert/boot.h>
 #include <kern/sched_prim.h>
 #include <kern/debug.h>
 
-#include "fakePPCStructs.h"
-#include "fakePPCDeviceTree.h"
 #include "boot_images.h"
 
 /* extern references */
 extern void pe_identify_machine(void * args);
-extern void initialize_screen(void *, unsigned int);
 
 /* private globals */
 PE_state_t  PE_state;
-dt_data     gMemoryMapNode;
-dt_data     gDriversProp;
-dt_data     gRootpathProp;
-dt_data     gCompatibleProp;
 
 /* Clock Frequency Info */
 clock_frequency_info_t gPEClockFrequencyInfo;
 
-void *gPEEFISystemTable     = 0;
-void *gPEEFIRuntimeServices = 0;
+void *gPEEFISystemTable;
+void *gPEEFIRuntimeServices;
 
 int PE_initialize_console( PE_Video * info, int op )
 {
     static int   last_console = -1;
-    Boot_Video   bootInfo;
-    Boot_Video * bInfo;
 
-    /*
-     * Refuse changes from outside pexpert.
-     * The video mode setup by the booter cannot be changed.
-     */
-    if ( info )
-    {
-        bootInfo.v_baseAddr = info->v_baseAddr;
-        bootInfo.v_rowBytes     = info->v_rowBytes;
-        bootInfo.v_width     = info->v_width;
-        bootInfo.v_height    = info->v_height;
-        bootInfo.v_depth     = info->v_depth;
-        bInfo = &bootInfo;
-        if (info == &PE_state.video) {
-            bootInfo.v_display   = info->v_display;
-        } else {
-            bootInfo.v_display  = GRAPHICS_MODE;
-        }
+    if (info) {
+       info->v_offset  = 0;
+       info->v_length  = 0;
+       info->v_display = GRAPHICS_MODE;
     }
-    else
-        bInfo = 0;
 
     switch ( op ) {
 
         case kPEDisableScreen:
-            initialize_screen((void *) bInfo, op);
+            initialize_screen(info, op);
             kprintf("kPEDisableScreen %d\n", last_console);
            if (!console_is_serial())
                last_console = switch_to_serial_console();
             break;
 
         case kPEEnableScreen:
-            initialize_screen((void *) bInfo, op);
+            initialize_screen(info, op);
+           if (info) PE_state.video = *info;
             kprintf("kPEEnableScreen %d\n", last_console);
             if( last_console != -1)
                 switch_to_old_console( last_console);
             break;
        
         default:
-            initialize_screen((void *) bInfo, op);
+            initialize_screen(info, op);
             break;
     }
 
@@ -118,8 +102,9 @@ void PE_init_iokit(void)
     boolean_t bootClutInitialized = FALSE;
     boolean_t norootInitialized = FALSE;
     DTEntry             entry;
-    int                        size;
-    void **            map;
+    unsigned int       size;
+    uint32_t           *map;
+       boot_progress_element *bootPict;
 
     PE_init_kprintf(TRUE);
     PE_init_printf(TRUE);
@@ -129,16 +114,17 @@ void PE_init_iokit(void)
     /*
      * Fetch the CLUT and the noroot image.
      */
-       boot_progress_element * bootPict;
 
-    if( kSuccess == DTLookupEntry(0, "/chosen/memory-map", &entry)) {
+    if( kSuccess == DTLookupEntry(NULL, "/chosen/memory-map", &entry)) {
        if( kSuccess == DTGetProperty(entry, "BootCLUT", (void **) &map, &size)) {
-           bcopy( map[0], appleClut8, sizeof(appleClut8) );
-            bootClutInitialized = TRUE;
-        }
+           if (sizeof(appleClut8) <= map[1]) {
+               bcopy( (void *)ml_static_ptovirt(map[0]), appleClut8, sizeof(appleClut8) );
+               bootClutInitialized = TRUE;
+           }
+       }
 
        if( kSuccess == DTGetProperty(entry, "Pict-FailedBoot", (void **) &map, &size)) {
-           bootPict = (boot_progress_element *) map[0];
+           bootPict = (boot_progress_element *) ml_static_ptovirt(map[0]);
            default_noroot.width  = bootPict->width;
            default_noroot.height = bootPict->height;
            default_noroot.dx     = 0;
@@ -171,7 +157,7 @@ void PE_init_iokit(void)
     vc_progress_initialize( &default_progress, default_progress_data,
                             (unsigned char *) appleClut8 );
 
-    (void) StartIOKit( PE_state.deviceTreeHead, PE_state.bootArgs, gPEEFIRuntimeServices, 0);
+    (void) StartIOKit( PE_state.deviceTreeHead, PE_state.bootArgs, gPEEFIRuntimeServices, NULL);
 }
 
 void PE_init_platform(boolean_t vm_initialized, void * _args)
@@ -183,33 +169,30 @@ void PE_init_platform(boolean_t vm_initialized, void * _args)
 
         // New EFI-style
         PE_state.bootArgs           = _args;
-        PE_state.deviceTreeHead            = args->deviceTreeP;
-        PE_state.video.v_baseAddr   = args->Video.v_baseAddr;
+        PE_state.deviceTreeHead            = (void *) ml_static_ptovirt(args->deviceTreeP);
+        PE_state.video.v_baseAddr   = args->Video.v_baseAddr; // remains physical address
         PE_state.video.v_rowBytes   = args->Video.v_rowBytes;
         PE_state.video.v_width     = args->Video.v_width;
         PE_state.video.v_height            = args->Video.v_height;
         PE_state.video.v_depth     = args->Video.v_depth;
         PE_state.video.v_display    = args->Video.v_display;
-        strcpy( PE_state.video.v_pixelFormat, "PPPPPPPP");
+        strlcpy(PE_state.video.v_pixelFormat, "PPPPPPPP",
+               sizeof(PE_state.video.v_pixelFormat));
     }
 
     if (!vm_initialized) {
                /* Hack! FIXME.. */ 
         outb(0x21, 0xff);   /* Maskout all interrupts Pic1 */
         outb(0xa1, 0xff);   /* Maskout all interrupts Pic2 */
         if (PE_state.deviceTreeHead) {
             DTInit(PE_state.deviceTreeHead);
-    }
+        }
 
         pe_identify_machine(args);
     } else {
-        DTEntry entry;
-        void *ptr;
-        uint32_t size;
-
         pe_init_debug();
     }
+
 }
 
 void PE_create_console( void )
@@ -233,7 +216,8 @@ void PE_display_icon( __unused unsigned int flags, __unused const char * name )
         vc_display_icon( &default_noroot, default_noroot_data );
 }
 
-extern boolean_t PE_get_hotkey( __unused unsigned char key )
+boolean_t
+PE_get_hotkey(__unused unsigned char key)
 {
     return (FALSE);
 }
@@ -290,5 +274,8 @@ PE_stub_poll_input(__unused unsigned int options, char * c)
 int (*PE_poll_input)(unsigned int options, char * c)
        = PE_stub_poll_input;
 
-
-
+boolean_t
+PE_reboot_on_panic(void)
+{
+       return FALSE;
+}