0001
0002
0003
0004
0005
0006
0007
0008 #include <linux/linkage.h>
0009
0010 #include <asm/asm-offsets.h>
0011 #include <asm/cpudata.h>
0012 #include <asm/page.h>
0013
0014 ENTRY(swsusp_arch_suspend)
0015 save %sp, -128, %sp
0016 save %sp, -128, %sp
0017 flushw
0018
0019 setuw saved_context, %g3
0020
0021
0022 rdpr %cwp, %g2
0023 stx %g2, [%g3 + SC_REG_CWP]
0024 rdpr %wstate, %g2
0025 stx %g2, [%g3 + SC_REG_WSTATE]
0026 stx %fp, [%g3 + SC_REG_FP]
0027
0028
0029 rdpr %tick, %g2
0030 stx %g2, [%g3 + SC_REG_TICK]
0031 rdpr %pstate, %g2
0032 stx %g2, [%g3 + SC_REG_PSTATE]
0033
0034
0035 stx %g4, [%g3 + SC_REG_G4]
0036 stx %g5, [%g3 + SC_REG_G5]
0037 stx %g6, [%g3 + SC_REG_G6]
0038
0039 call swsusp_save
0040 nop
0041
0042 mov %o0, %i0
0043 restore
0044
0045 mov %o0, %i0
0046 ret
0047 restore
0048
0049 ENTRY(swsusp_arch_resume)
0050
0051 sethi %hi(restore_pblist), %l0
0052 ldx [%l0 + %lo(restore_pblist)], %l0
0053
0054 call __flush_tlb_all
0055 nop
0056
0057
0058 sethi %hi(PAGE_OFFSET), %g7
0059 ldx [%g7 + %lo(PAGE_OFFSET)], %g7
0060
0061 setuw (PAGE_SIZE-8), %g3
0062
0063
0064 rd %asi, %g1
0065 wr %g0, ASI_PHYS_USE_EC, %asi
0066
0067 ba fill_itlb
0068 nop
0069
0070 pbe_loop:
0071 cmp %l0, %g0
0072 be restore_ctx
0073 sub %l0, %g7, %l0
0074
0075 ldxa [%l0 ] %asi, %l1
0076 ldxa [%l0 + 8] %asi, %l2
0077
0078
0079 sub %l1, %g7, %l1
0080 sub %l2, %g7, %l2
0081
0082 mov %g3, %l3
0083 copy_loop:
0084 ldxa [%l1 + %l3] ASI_PHYS_USE_EC, %g2
0085 stxa %g2, [%l2 + %l3] ASI_PHYS_USE_EC
0086 cmp %l3, %g0
0087 bne copy_loop
0088 sub %l3, 8, %l3
0089
0090
0091 ba pbe_loop
0092 ldxa [%l0 + 16] %asi, %l0
0093
0094 restore_ctx:
0095 setuw saved_context, %g3
0096
0097
0098 wrpr %g0, 0, %canrestore
0099 wrpr %g0, 0, %otherwin
0100 wrpr %g0, 6, %cansave
0101 wrpr %g0, 0, %cleanwin
0102
0103 ldxa [%g3 + SC_REG_CWP] %asi, %g2
0104 wrpr %g2, %cwp
0105 ldxa [%g3 + SC_REG_WSTATE] %asi, %g2
0106 wrpr %g2, %wstate
0107 ldxa [%g3 + SC_REG_FP] %asi, %fp
0108
0109
0110 ldxa [%g3 + SC_REG_PSTATE] %asi, %g2
0111 wrpr %g2, %pstate
0112 ldxa [%g3 + SC_REG_TICK] %asi, %g2
0113 wrpr %g2, %tick
0114
0115
0116 ldxa [%g3 + SC_REG_G4] %asi, %g4
0117 ldxa [%g3 + SC_REG_G5] %asi, %g5
0118 ldxa [%g3 + SC_REG_G6] %asi, %g6
0119
0120 wr %g1, %g0, %asi
0121
0122 restore
0123 restore
0124
0125 wrpr %g0, 14, %pil
0126
0127 retl
0128 mov %g0, %o0
0129
0130 fill_itlb:
0131 ba pbe_loop
0132 wrpr %g0, 15, %pil