118feae1bSmatt/*- 218feae1bSmatt * Copyright (c) 2012 The NetBSD Foundation, Inc. 318feae1bSmatt * All rights reserved. 418feae1bSmatt * 518feae1bSmatt * This code is derived from software contributed to The NetBSD Foundation 618feae1bSmatt * by Matt Thomas of 3am Software Foundry. 718feae1bSmatt * 818feae1bSmatt * Redistribution and use in source and binary forms, with or without 918feae1bSmatt * modification, are permitted provided that the following conditions 1018feae1bSmatt * are met: 1118feae1bSmatt * 1. Redistributions of source code must retain the above copyright 1218feae1bSmatt * notice, this list of conditions and the following disclaimer. 1318feae1bSmatt * 2. Redistributions in binary form must reproduce the above copyright 1418feae1bSmatt * notice, this list of conditions and the following disclaimer in the 1518feae1bSmatt * documentation and/or other materials provided with the distribution. 1618feae1bSmatt * 1718feae1bSmatt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 1818feae1bSmatt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 1918feae1bSmatt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2018feae1bSmatt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 2118feae1bSmatt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2218feae1bSmatt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2318feae1bSmatt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2418feae1bSmatt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2518feae1bSmatt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2618feae1bSmatt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2718feae1bSmatt * POSSIBILITY OF SUCH DAMAGE. 2818feae1bSmatt */ 2918feae1bSmatt 3018feae1bSmatt#include "opt_cputypes.h" 3118feae1bSmatt 3218feae1bSmatt#include <machine/asm.h> 3318feae1bSmatt#include "assym.h" 3418feae1bSmatt 35*bc0216ccSskrllRCSID("$NetBSD: pmap_vfp.S,v 1.7 2021/10/17 08:48:10 skrll Exp $") 361ee1fc76Smatt 3718feae1bSmatt/* 3882296793Smatt * This zeroes a page 64-bytes at a time. 64 was chosen over 32 since 3918feae1bSmatt * 64 is the cache line size of the Cortex-A8. 4018feae1bSmatt */ 4182296793Smatt/* LINTSTUB: void bzero_page_vfp(vaddr_t); */ 4282296793SmattENTRY(bzero_page_vfp) 43b17bcc6bSmatt push {r0, lr} 44fecfceb4Smatt bl _C_LABEL(vfp_kernel_acquire) 45b17bcc6bSmatt pop {r0, lr} 4618feae1bSmatt#if (CPU_CORTEX == 0) 4718feae1bSmatt mov ip, #0 4818feae1bSmatt vmov s0, ip 4918feae1bSmatt vmov s1, ip 5018feae1bSmatt vmov.f64 d1, d0 5118feae1bSmatt vmov.f64 d2, d0 5218feae1bSmatt vmov.f64 d3, d0 5318feae1bSmatt vmov.f64 d4, d0 5418feae1bSmatt vmov.f64 d5, d0 5518feae1bSmatt vmov.f64 d6, d0 5618feae1bSmatt vmov.f64 d7, d0 5718feae1bSmatt#else 5818feae1bSmatt veor q0, q0, q0 5918feae1bSmatt veor q1, q1, q1 6018feae1bSmatt veor q2, q2, q2 6118feae1bSmatt veor q3, q3, q3 6218feae1bSmatt#endif 6318feae1bSmatt add r2, r0, #PAGE_SIZE 6418feae1bSmatt1: vstmia r0!, {d0-d7} 6518feae1bSmatt vstmia r0!, {d0-d7} 6618feae1bSmatt vstmia r0!, {d0-d7} 6718feae1bSmatt vstmia r0!, {d0-d7} 6818feae1bSmatt cmp r0, r2 6918feae1bSmatt blt 1b 70fecfceb4Smatt b _C_LABEL(vfp_kernel_release) /* tailcall the vfp release */ 7182296793SmattEND(bzero_page_vfp) 7218feae1bSmatt 7318feae1bSmatt/* 7482296793Smatt * This copies a page 64-bytes at a time. 64 was chosen over 32 since 7518feae1bSmatt * 64 is the cache line size of the Cortex-A8. 7618feae1bSmatt */ 7782296793Smatt/* LINTSTUB: void bcopy_page_vfp(vaddr_t, vaddr_t); */ 7882296793SmattENTRY(bcopy_page_vfp) 795c340aedSmatt#ifdef _ARM_ARCH_DWORD_OK 8018feae1bSmatt pld [r0] @ preload the first 128 bytes 8118feae1bSmatt pld [r0, #32] 8218feae1bSmatt pld [r0, #64] 8318feae1bSmatt pld [r0, #96] 845c340aedSmatt#endif 85fecfceb4Smatt str lr, [sp, #-8]! 86b17bcc6bSmatt push {r0, r1} 87fecfceb4Smatt bl _C_LABEL(vfp_kernel_acquire) 88b17bcc6bSmatt pop {r0, r1} 89b17bcc6bSmatt ldr lr, [sp], #8 /* fetch LR */ 9018feae1bSmatt add r2, r0, #PAGE_SIZE-128 915c340aedSmatt1: 925c340aedSmatt#ifdef _ARM_ARCH_DWORD_OK 935c340aedSmatt pld [r0, #128] @ preload the next 128 9418feae1bSmatt pld [r0, #160] 9518feae1bSmatt pld [r0, #192] 9618feae1bSmatt pld [r0, #224] 975c340aedSmatt#endif 9818feae1bSmatt2: vldmia r0!, {d0-d7} @ read 0-63 9918feae1bSmatt vstmia r1!, {d0-d7} @ write 0-63 10018feae1bSmatt vldmia r0!, {d0-d7} @ read 64-127 10118feae1bSmatt vstmia r1!, {d0-d7} @ write 64-127 10218feae1bSmatt cmp r0, r2 10318feae1bSmatt blt 1b 10418feae1bSmatt beq 2b 105fecfceb4Smatt b _C_LABEL(vfp_kernel_release) /* tailcall the vfp release */ 10682296793SmattEND(bcopy_page_vfp) 107