2 * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_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 License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
30 #include <ppc/proc_reg.h>
34 This code is linked into the kernel but part of the "__HIB" section, which means
35 its used by code running in the special context of restoring the kernel text and data
36 from the hibernation image read by the booter. hibernate_kernel_entrypoint() and everything
37 it calls or references (ie. hibernate_restore_phys_page())
38 needs to be careful to only touch memory also in the "__HIB" section.
43 hibernate_restore_phys_page(uint64_t src, uint64_t dst, uint32_t len, uint32_t procFlags);
47 .globl EXT(hibernate_restore_phys_page)
48 .globl EXT(hibernate_machine_entrypoint)
50 LEXT(hibernate_restore_phys_page)
53 bne hibernate_restore_phys_page64
55 srwi r10,r7,5 ; r10 <- 32-byte chunks to xfer
58 beq hibernate_restore_phys_pageFlush
60 hibernate_restore_phys_pageCopy:
70 dcbz 0,r6 ; avoid prefetch of next cache line
89 bdnz hibernate_restore_phys_pageCopy ; loop if more chunks
92 hibernate_restore_phys_pageFlush:
100 bdnz hibernate_restore_phys_pageFlush ; loop if more chunks
104 hibernate_restore_phys_page64:
105 rlwinm r3,r3,0,1,0 ; Duplicate high half of long long paddr into top of reg
106 rlwimi r3,r4,0,0,31 ; Combine bottom of long long to full 64-bits
107 rlwinm r4,r5,0,1,0 ; Duplicate high half of long long paddr into top of reg
108 rlwimi r4,r6,0,0,31 ; Combine bottom of long long to full 64-bits
110 mfmsr r9 ; Get the MSR
111 li r0,1 ; Note - we use this in a couple places below
112 rldimi r9,r0,63,MSR_SF_BIT ; set SF on in MSR we will copy with
113 mtmsrd r9 ; turn 64-bit addressing on
114 isync ; wait for it to happen
116 srwi r10,r7,7 ; r10 <- 128-byte chunks to xfer
119 beq hibernate_restore_phys_page64Flush
121 hibernate_restore_phys_page64Copy:
131 dcbz128 0,r4 ; avoid prefetch of next cache line
141 ld r0,64(r3) ; load 2nd half of chunk
168 bdnz hibernate_restore_phys_page64Copy ; loop if more chunks
171 hibernate_restore_phys_page64Done:
172 mfmsr r9 ; Get the MSR we used to copy
173 rldicl r9,r9,0,MSR_SF_BIT+1 ; clear SF
174 mtmsrd r9 ; turn 64-bit mode off
175 isync ; wait for it to happen
178 hibernate_restore_phys_page64Flush:
187 bdnz hibernate_restore_phys_page64Flush ; loop if more chunks
188 b hibernate_restore_phys_page64Done
190 LEXT(hibernate_machine_entrypoint)
191 b EXT(hibernate_kernel_entrypoint)