]> git.saurik.com Git - apple/xnu.git/blobdiff - iokit/Kernel/IOHibernateRestoreKernel.c
xnu-1228.5.20.tar.gz
[apple/xnu.git] / iokit / Kernel / IOHibernateRestoreKernel.c
index b1b99fbac98be36aa586d812ce86823f3e94663c..405d646463ccc51a91bf3923747d3f614d4e4b31 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2004-2006 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
@@ -33,6 +33,7 @@
 #include <IOKit/IOLib.h>
 #include <pexpert/boot.h>
 #include <crypto/aes.h>
+#include <libkern/libkern.h>
 
 #include "WKdm.h"
 #include "IOHibernateInternal.h"
@@ -101,6 +102,11 @@ hibernate_sum(uint8_t *buf, int32_t len)
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 
+static __inline__ unsigned int cntlzw(unsigned int num)
+{
+       return clz(num);
+}
+
 static hibernate_bitmap_t *
 hibernate_page_bitmap(hibernate_page_list_t * list, uint32_t page)
 {
@@ -114,7 +120,7 @@ hibernate_page_bitmap(hibernate_page_list_t * list, uint32_t page)
        bitmap = (hibernate_bitmap_t *) &bitmap->bitmap[bitmap->bitmapwords];
     }
     if (bank == list->bank_count)
-       bitmap = 0;
+       bitmap = NULL;
        
     return (bitmap);
 }
@@ -137,7 +143,7 @@ hibernate_page_bitmap_pin(hibernate_page_list_t * list, uint32_t * pPage)
        bitmap = (hibernate_bitmap_t *) &bitmap->bitmap[bitmap->bitmapwords];
     }
     if (bank == list->bank_count)
-       bitmap = 0;
+       bitmap = NULL;
        
     return (bitmap);
 }
@@ -231,9 +237,6 @@ hibernate_page_list_grab(hibernate_page_list_t * list, uint32_t * pNextFree)
        }
     }
 
-    if (!bitmap)
-       IOPanic(__FUNCTION__);
-
     return (nextFree);
 }
 
@@ -304,6 +307,7 @@ hibernate_kernel_entrypoint(IOHibernateImageHeader * header,
     uint32_t lastImagePage;
     uint32_t lastMapPage;
     uint32_t lastPageIndexPage;
+    ResetProc proc;
 
     C_ASSERT(sizeof(IOHibernateImageHeader) == 512);
 
@@ -507,12 +511,10 @@ hibernate_kernel_entrypoint(IOHibernateImageHeader * header,
     gIOHibernateState = kIOHibernateStateWakingFromHibernate;
 
 #if __ppc__
-    ResetProc proc;
     proc = (ResetProc) 0x100;
     __asm__ volatile("ori 0, 0, 0" : : );
     proc();
 #elif __i386__
-    ResetProc proc;
     proc = (ResetProc) acpi_wake_prot_entry;
     // flush caches
     __asm__("wbinvd");
@@ -521,4 +523,3 @@ hibernate_kernel_entrypoint(IOHibernateImageHeader * header,
   
     return -1;
 }
-