| 164 | } |
| 165 | |
| 166 | void |
| 167 | vfp_save_state(struct thread *td, struct pcb *pcb) |
| 168 | { |
| 169 | uint32_t cpacr; |
| 170 | |
| 171 | KASSERT(pcb != NULL, ("NULL vfp pcb")); |
| 172 | KASSERT(td == NULL || td->td_pcb == pcb, ("Invalid vfp pcb")); |
| 173 | |
| 174 | /* |
| 175 | * savectx() will be called on panic with dumppcb as an argument, |
| 176 | * dumppcb doesn't have pcb_fpusaved set, so set it to save |
| 177 | * the VFP registers. |
| 178 | */ |
| 179 | if (pcb->pcb_fpusaved == NULL) |
| 180 | pcb->pcb_fpusaved = &pcb->pcb_fpustate; |
| 181 | |
| 182 | if (td == NULL) |
| 183 | td = curthread; |
| 184 | |
| 185 | critical_enter(); |
| 186 | /* |
| 187 | * Only store the registers if the VFP is enabled, |
| 188 | * i.e. return if we are trapping on FP access. |
| 189 | */ |
| 190 | cpacr = READ_SPECIALREG(cpacr_el1); |
| 191 | if ((cpacr & CPACR_FPEN_MASK) == CPACR_FPEN_TRAP_NONE) { |
| 192 | KASSERT(PCPU_GET(fpcurthread) == td, |
| 193 | ("Storing an invalid VFP state")); |
| 194 | |
| 195 | vfp_store(pcb->pcb_fpusaved); |
| 196 | dsb(ish); |
| 197 | vfp_disable(); |
| 198 | } |
| 199 | critical_exit(); |
| 200 | } |
| 201 | |
| 202 | void |
| 203 | vfp_restore_state(void) |
no test coverage detected