| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: cpufunc_asm_armv8.S,v 1.6 2020/07/01 07:59:16 ryo Exp $ */ | | 1 | /* $NetBSD: cpufunc_asm_armv8.S,v 1.7 2020/07/19 07:18:07 ryo Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2014 Robin Randhawa | | 4 | * Copyright (c) 2014 Robin Randhawa |
5 | * Copyright (c) 2015 The FreeBSD Foundation | | 5 | * Copyright (c) 2015 The FreeBSD Foundation |
6 | * All rights reserved. | | 6 | * All rights reserved. |
7 | * | | 7 | * |
8 | * Portions of this software were developed by Andrew Turner | | 8 | * Portions of this software were developed by Andrew Turner |
9 | * under sponsorship from the FreeBSD Foundation | | 9 | * under sponsorship from the FreeBSD Foundation |
10 | * | | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | | 11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions | | 12 | * modification, are permitted provided that the following conditions |
13 | * are met: | | 13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright | | 14 | * 1. Redistributions of source code must retain the above copyright |
| @@ -33,50 +33,50 @@ | | | @@ -33,50 +33,50 @@ |
33 | */ | | 33 | */ |
34 | | | 34 | |
35 | #include "opt_cputypes.h" | | 35 | #include "opt_cputypes.h" |
36 | #include "opt_multiprocessor.h" | | 36 | #include "opt_multiprocessor.h" |
37 | #include <aarch64/asm.h> | | 37 | #include <aarch64/asm.h> |
38 | | | 38 | |
39 | .text | | 39 | .text |
40 | .align 2 | | 40 | .align 2 |
41 | | | 41 | |
42 | /* | | 42 | /* |
43 | * Macro to handle the cache. This takes the start address in x0, length | | 43 | * Macro to handle the cache. This takes the start address in x0, length |
44 | * in x1. It will corrupt x2-x5. | | 44 | * in x1. It will corrupt x2-x5. |
45 | */ | | 45 | */ |
46 | .macro cache_handle_range dcop = 0, icop = 0 | | 46 | .macro cache_handle_range dcop = "", icop = "" |
47 | mrs x3, ctr_el0 | | 47 | mrs x3, ctr_el0 |
48 | mov x4, #4 /* size of word */ | | 48 | mov x4, #4 /* size of word */ |
49 | .if \dcop != 0 | | 49 | .ifnb \dcop |
50 | ubfx x2, x3, #16, #4 /* x2 = D cache shift */ | | 50 | ubfx x2, x3, #16, #4 /* x2 = D cache shift */ |
51 | lsl x2, x4, x2 /* x2 = D cache line size */ | | 51 | lsl x2, x4, x2 /* x2 = D cache line size */ |
52 | .endif | | 52 | .endif |
53 | .if \icop != 0 | | 53 | .ifnb \icop |
54 | and x3, x3, #15 /* x3 = I cache shift */ | | 54 | and x3, x3, #15 /* x3 = I cache shift */ |
55 | lsl x3, x4, x3 /* x3 = I cache line size */ | | 55 | lsl x3, x4, x3 /* x3 = I cache line size */ |
56 | .endif | | 56 | .endif |
57 | .if \dcop != 0 | | 57 | .ifnb \dcop |
58 | sub x4, x2, #1 /* Get the address mask */ | | 58 | sub x4, x2, #1 /* Get the address mask */ |
59 | and x4, x0, x4 /* Get the low bits of the address */ | | 59 | and x4, x0, x4 /* Get the low bits of the address */ |
60 | add x5, x1, x4 /* Add these to the size */ | | 60 | add x5, x1, x4 /* Add these to the size */ |
61 | bic x4, x0, x4 /* Clear the low bit of the address */ | | 61 | bic x4, x0, x4 /* Clear the low bit of the address */ |
62 | 1: | | 62 | 1: |
63 | dc \dcop, x4 | | 63 | dc \dcop, x4 |
64 | add x4, x4, x2 /* Move to the next line */ | | 64 | add x4, x4, x2 /* Move to the next line */ |
65 | subs x5, x5, x2 /* Reduce the size */ | | 65 | subs x5, x5, x2 /* Reduce the size */ |
66 | b.hi 1b /* Check if we are done */ | | 66 | b.hi 1b /* Check if we are done */ |
67 | dsb ish | | 67 | dsb ish |
68 | .endif | | 68 | .endif |
69 | .if \icop != 0 | | 69 | .ifnb \icop |
70 | sub x4, x3, #1 /* Get the address mask */ | | 70 | sub x4, x3, #1 /* Get the address mask */ |
71 | and x4, x0, x4 /* Get the low bits of the address */ | | 71 | and x4, x0, x4 /* Get the low bits of the address */ |
72 | add x5, x1, x4 /* Add these to the size */ | | 72 | add x5, x1, x4 /* Add these to the size */ |
73 | bic x4, x0, x4 /* Clear the low bit of the address */ | | 73 | bic x4, x0, x4 /* Clear the low bit of the address */ |
74 | 1: | | 74 | 1: |
75 | ic \icop, x4 | | 75 | ic \icop, x4 |
76 | add x4, x4, x3 /* Move to the next line */ | | 76 | add x4, x4, x3 /* Move to the next line */ |
77 | subs x5, x5, x3 /* Reduce the size */ | | 77 | subs x5, x5, x3 /* Reduce the size */ |
78 | b.hi 1b /* Check if we are done */ | | 78 | b.hi 1b /* Check if we are done */ |
79 | dsb ish | | 79 | dsb ish |
80 | isb | | 80 | isb |
81 | .endif | | 81 | .endif |
82 | .endm | | 82 | .endm |