| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: sysreg.h,v 1.7 2020/11/02 08:36:54 skrll Exp $ */ | | 1 | /* $NetBSD: sysreg.h,v 1.8 2020/11/02 08:37:59 skrll Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2014 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2014 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Matt Thomas of 3am Software Foundry. | | 8 | * by Matt Thomas of 3am Software Foundry. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -188,30 +188,33 @@ riscvreg_cycle_read(void) | | | @@ -188,30 +188,33 @@ riscvreg_cycle_read(void) |
188 | "csrr\t%[__hi0], cycleh" | | 188 | "csrr\t%[__hi0], cycleh" |
189 | "\n\t" "csrr\t%[__lo0], cycle" | | 189 | "\n\t" "csrr\t%[__lo0], cycle" |
190 | "\n\t" "csrr\t%[__hi1], cycleh" | | 190 | "\n\t" "csrr\t%[__hi1], cycleh" |
191 | : [__hi0] "=r"(__hi0), | | 191 | : [__hi0] "=r"(__hi0), |
192 | [__lo0] "=r"(__lo0), | | 192 | [__lo0] "=r"(__lo0), |
193 | [__hi1] "=r"(__hi1)); | | 193 | [__hi1] "=r"(__hi1)); |
194 | } while (__hi0 != __hi1); | | 194 | } while (__hi0 != __hi1); |
195 | return ((uint64_t)__hi0 << 32) | (uint64_t)__lo0; | | 195 | return ((uint64_t)__hi0 << 32) | (uint64_t)__lo0; |
196 | #endif | | 196 | #endif |
197 | } | | 197 | } |
198 | | | 198 | |
199 | #ifdef _LP64 | | 199 | #ifdef _LP64 |
200 | #define SATP_MODE __BITS(63,60) | | 200 | #define SATP_MODE __BITS(63,60) |
| | | 201 | #define SATP_MODE_SV39 8 |
| | | 202 | #define SATP_MODE_SV48 9 |
201 | #define SATP_ASID __BITS(59,44) | | 203 | #define SATP_ASID __BITS(59,44) |
202 | #define SATP_PPN __BITS(43,0) | | 204 | #define SATP_PPN __BITS(43,0) |
203 | #else | | 205 | #else |
204 | #define SATP_MODE __BIT(31) | | 206 | #define SATP_MODE __BIT(31) |
| | | 207 | #define SATP_MODE_SV32 1 |
205 | #define SATP_ASID __BITS(30,22) | | 208 | #define SATP_ASID __BITS(30,22) |
206 | #define SATP_PPN __BITS(21,0) | | 209 | #define SATP_PPN __BITS(21,0) |
207 | #endif | | 210 | #endif |
208 | | | 211 | |
209 | static inline uint32_t | | 212 | static inline uint32_t |
210 | riscvreg_asid_read(void) | | 213 | riscvreg_asid_read(void) |
211 | { | | 214 | { |
212 | uintptr_t satp; | | 215 | uintptr_t satp; |
213 | __asm __volatile("csrr %0, satp" : "=r" (satp)); | | 216 | __asm __volatile("csrr %0, satp" : "=r" (satp)); |
214 | return __SHIFTOUT(satp, SATP_ASID); | | 217 | return __SHIFTOUT(satp, SATP_ASID); |
215 | } | | 218 | } |
216 | | | 219 | |
217 | static inline void | | 220 | static inline void |