2 * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
32 #include <ppc/proc_reg.h>
36 This code is linked into the kernel but part of the "__HIB" section, which means
37 its used by code running in the special context of restoring the kernel text and data
38 from the hibernation image read by the booter. hibernate_kernel_entrypoint() and everything
39 it calls or references (ie. hibernate_restore_phys_page())
40 needs to be careful to only touch memory also in the "__HIB" section.
45 hibernate_restore_phys_page(uint64_t src, uint64_t dst, uint32_t len, uint32_t procFlags);
49 .globl EXT(hibernate_restore_phys_page)
50 .globl EXT(hibernate_machine_entrypoint)
52 LEXT(hibernate_restore_phys_page)
55 bne hibernate_restore_phys_page64
57 srwi r10,r7,5 ; r10 <- 32-byte chunks to xfer
60 beq hibernate_restore_phys_pageFlush
62 hibernate_restore_phys_pageCopy:
72 dcbz 0,r6 ; avoid prefetch of next cache line
91 bdnz hibernate_restore_phys_pageCopy ; loop if more chunks
94 hibernate_restore_phys_pageFlush:
102 bdnz hibernate_restore_phys_pageFlush ; loop if more chunks
106 hibernate_restore_phys_page64:
107 rlwinm r3,r3,0,1,0 ; Duplicate high half of long long paddr into top of reg
108 rlwimi r3,r4,0,0,31 ; Combine bottom of long long to full 64-bits
109 rlwinm r4,r5,0,1,0 ; Duplicate high half of long long paddr into top of reg
110 rlwimi r4,r6,0,0,31 ; Combine bottom of long long to full 64-bits
112 mfmsr r9 ; Get the MSR
113 li r0,1 ; Note - we use this in a couple places below
114 rldimi r9,r0,63,MSR_SF_BIT ; set SF on in MSR we will copy with
115 mtmsrd r9 ; turn 64-bit addressing on
116 isync ; wait for it to happen
118 srwi r10,r7,7 ; r10 <- 128-byte chunks to xfer
121 beq hibernate_restore_phys_page64Flush
123 hibernate_restore_phys_page64Copy:
133 dcbz128 0,r4 ; avoid prefetch of next cache line
143 ld r0,64(r3) ; load 2nd half of chunk
170 bdnz hibernate_restore_phys_page64Copy ; loop if more chunks
173 hibernate_restore_phys_page64Done:
174 mfmsr r9 ; Get the MSR we used to copy
175 rldicl r9,r9,0,MSR_SF_BIT+1 ; clear SF
176 mtmsrd r9 ; turn 64-bit mode off
177 isync ; wait for it to happen
180 hibernate_restore_phys_page64Flush:
189 bdnz hibernate_restore_phys_page64Flush ; loop if more chunks
190 b hibernate_restore_phys_page64Done
192 LEXT(hibernate_machine_entrypoint)
193 b EXT(hibernate_kernel_entrypoint)