Only use CPACR register for ARM11 and CORTEX cores. Add VFP ids for other CORTEX CPUs.diff -r1.67 -r1.68 src/sys/arch/arm/include/armreg.h
(matt)
--- src/sys/arch/arm/include/armreg.h 2012/09/22 01:44:12 1.67
+++ src/sys/arch/arm/include/armreg.h 2012/09/22 19:45:53 1.68
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: armreg.h,v 1.67 2012/09/22 01:44:12 matt Exp $ */ | 1 | /* $NetBSD: armreg.h,v 1.68 2012/09/22 19:45:53 matt Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1998, 2001 Ben Harris | 4 | * Copyright (c) 1998, 2001 Ben Harris | |
5 | * Copyright (c) 1994-1996 Mark Brinicombe. | 5 | * Copyright (c) 1994-1996 Mark Brinicombe. | |
6 | * Copyright (c) 1994 Brini. | 6 | * Copyright (c) 1994 Brini. | |
7 | * All rights reserved. | 7 | * All rights reserved. | |
8 | * | 8 | * | |
9 | * This code is derived from software written for Brini by Mark Brinicombe | 9 | * This code is derived from software written for Brini by Mark Brinicombe | |
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 | |
@@ -311,26 +311,35 @@ | @@ -311,26 +311,35 @@ | |||
311 | #define CPU_CONTROL_V4COMPAT 0x00008000 /* L4: ARMv4 compat LDR R15 etc */ | 311 | #define CPU_CONTROL_V4COMPAT 0x00008000 /* L4: ARMv4 compat LDR R15 etc */ | |
312 | #define CPU_CONTROL_FI_ENABLE 0x00200000 /* FI: Low interrupt latency */ | 312 | #define CPU_CONTROL_FI_ENABLE 0x00200000 /* FI: Low interrupt latency */ | |
313 | #define CPU_CONTROL_UNAL_ENABLE 0x00400000 /* U: unaligned data access */ | 313 | #define CPU_CONTROL_UNAL_ENABLE 0x00400000 /* U: unaligned data access */ | |
314 | #define CPU_CONTROL_XP_ENABLE 0x00800000 /* XP: extended page table */ | 314 | #define CPU_CONTROL_XP_ENABLE 0x00800000 /* XP: extended page table */ | |
315 | #define CPU_CONTROL_V_ENABLE 0x01000000 /* VE: Interrupt vectors enable */ | 315 | #define CPU_CONTROL_V_ENABLE 0x01000000 /* VE: Interrupt vectors enable */ | |
316 | #define CPU_CONTROL_EX_BEND 0x02000000 /* EE: exception endianness */ | 316 | #define CPU_CONTROL_EX_BEND 0x02000000 /* EE: exception endianness */ | |
317 | #define CPU_CONTROL_NMFI 0x08000000 /* NMFI: Non maskable FIQ */ | 317 | #define CPU_CONTROL_NMFI 0x08000000 /* NMFI: Non maskable FIQ */ | |
318 | #define CPU_CONTROL_TR_ENABLE 0x10000000 /* TRE: */ | 318 | #define CPU_CONTROL_TR_ENABLE 0x10000000 /* TRE: */ | |
319 | #define CPU_CONTROL_AF_ENABLE 0x20000000 /* AFE: Access flag enable */ | 319 | #define CPU_CONTROL_AF_ENABLE 0x20000000 /* AFE: Access flag enable */ | |
320 | #define CPU_CONTROL_TE_ENABLE 0x40000000 /* TE: Thumb Exception enable */ | 320 | #define CPU_CONTROL_TE_ENABLE 0x40000000 /* TE: Thumb Exception enable */ | |
321 | 321 | |||
322 | #define CPU_CONTROL_IDC_ENABLE CPU_CONTROL_DC_ENABLE | 322 | #define CPU_CONTROL_IDC_ENABLE CPU_CONTROL_DC_ENABLE | |
323 | 323 | |||
324 | /* ARMv6/ARMv7 Co-Processor Access Control Register (CP15, 0, c1, c0, 2) */ | |||
325 | #define CPACR_V7_ASEDIS 0x80000000 /* Disable Advanced SIMD Ext. */ | |||
326 | #define CPACR_V7_D32DIS 0x40000000 /* Disable VFP regs 15-31 */ | |||
327 | #define CPACR_CPn(n) (3 << (2*n)) | |||
328 | #define CPACR_NOACCESS 0 /* reset value */ | |||
329 | #define CPACR_PRIVED 1 /* Privileged mode access */ | |||
330 | #define CPACR_RESERVED 2 | |||
331 | #define CPACR_ALL 3 /* Privileged and User mode access */ | |||
332 | ||||
324 | /* ARM11x6 Auxiliary Control Register (CP15 register 1, opcode2 1) */ | 333 | /* ARM11x6 Auxiliary Control Register (CP15 register 1, opcode2 1) */ | |
325 | #define ARM11X6_AUXCTL_RS 0x00000001 /* return stack */ | 334 | #define ARM11X6_AUXCTL_RS 0x00000001 /* return stack */ | |
326 | #define ARM11X6_AUXCTL_DB 0x00000002 /* dynamic branch prediction */ | 335 | #define ARM11X6_AUXCTL_DB 0x00000002 /* dynamic branch prediction */ | |
327 | #define ARM11X6_AUXCTL_SB 0x00000004 /* static branch prediction */ | 336 | #define ARM11X6_AUXCTL_SB 0x00000004 /* static branch prediction */ | |
328 | #define ARM11X6_AUXCTL_TR 0x00000008 /* MicroTLB replacement strat. */ | 337 | #define ARM11X6_AUXCTL_TR 0x00000008 /* MicroTLB replacement strat. */ | |
329 | #define ARM11X6_AUXCTL_EX 0x00000010 /* exclusive L1/L2 cache */ | 338 | #define ARM11X6_AUXCTL_EX 0x00000010 /* exclusive L1/L2 cache */ | |
330 | #define ARM11X6_AUXCTL_RA 0x00000020 /* clean entire cache disable */ | 339 | #define ARM11X6_AUXCTL_RA 0x00000020 /* clean entire cache disable */ | |
331 | #define ARM11X6_AUXCTL_RV 0x00000040 /* block transfer cache disable */ | 340 | #define ARM11X6_AUXCTL_RV 0x00000040 /* block transfer cache disable */ | |
332 | #define ARM11X6_AUXCTL_CZ 0x00000080 /* restrict cache size */ | 341 | #define ARM11X6_AUXCTL_CZ 0x00000080 /* restrict cache size */ | |
333 | 342 | |||
334 | /* ARM1136 Auxiliary Control Register (CP15 register 1, opcode2 1) */ | 343 | /* ARM1136 Auxiliary Control Register (CP15 register 1, opcode2 1) */ | |
335 | #define ARM1136_AUXCTL_PFI 0x80000000 /* PFI: partial FI mode. */ | 344 | #define ARM1136_AUXCTL_PFI 0x80000000 /* PFI: partial FI mode. */ | |
336 | /* This is an undocumented flag | 345 | /* This is an undocumented flag | |
@@ -560,28 +569,30 @@ ARMREG_READ_INLINE(mmfr1, "p15,0,%0,c0,c | @@ -560,28 +569,30 @@ ARMREG_READ_INLINE(mmfr1, "p15,0,%0,c0,c | |||
560 | ARMREG_READ_INLINE(mmfr2, "p15,0,%0,c0,c1,6") /* Memory Model Feature Register 2 */ | 569 | ARMREG_READ_INLINE(mmfr2, "p15,0,%0,c0,c1,6") /* Memory Model Feature Register 2 */ | |
561 | ARMREG_READ_INLINE(mmfr3, "p15,0,%0,c0,c1,7") /* Memory Model Feature Register 3 */ | 570 | ARMREG_READ_INLINE(mmfr3, "p15,0,%0,c0,c1,7") /* Memory Model Feature Register 3 */ | |
562 | ARMREG_READ_INLINE(isar0, "p15,0,%0,c0,c2,0") /* Instruction Set Attribute Register 0 */ | 571 | ARMREG_READ_INLINE(isar0, "p15,0,%0,c0,c2,0") /* Instruction Set Attribute Register 0 */ | |
563 | ARMREG_READ_INLINE(isar1, "p15,0,%0,c0,c2,1") /* Instruction Set Attribute Register 1 */ | 572 | ARMREG_READ_INLINE(isar1, "p15,0,%0,c0,c2,1") /* Instruction Set Attribute Register 1 */ | |
564 | ARMREG_READ_INLINE(isar2, "p15,0,%0,c0,c2,2") /* Instruction Set Attribute Register 2 */ | 573 | ARMREG_READ_INLINE(isar2, "p15,0,%0,c0,c2,2") /* Instruction Set Attribute Register 2 */ | |
565 | ARMREG_READ_INLINE(isar3, "p15,0,%0,c0,c2,3") /* Instruction Set Attribute Register 3 */ | 574 | ARMREG_READ_INLINE(isar3, "p15,0,%0,c0,c2,3") /* Instruction Set Attribute Register 3 */ | |
566 | ARMREG_READ_INLINE(isar4, "p15,0,%0,c0,c2,4") /* Instruction Set Attribute Register 4 */ | 575 | ARMREG_READ_INLINE(isar4, "p15,0,%0,c0,c2,4") /* Instruction Set Attribute Register 4 */ | |
567 | ARMREG_READ_INLINE(isar5, "p15,0,%0,c0,c2,5") /* Instruction Set Attribute Register 5 */ | 576 | ARMREG_READ_INLINE(isar5, "p15,0,%0,c0,c2,5") /* Instruction Set Attribute Register 5 */ | |
568 | ARMREG_READ_INLINE(ccsidr, "p15,1,%0,c0,c0,0") /* Cache Size ID Register */ | 577 | ARMREG_READ_INLINE(ccsidr, "p15,1,%0,c0,c0,0") /* Cache Size ID Register */ | |
569 | ARMREG_READ_INLINE(clidr, "p15,1,%0,c0,c0,1") /* Cache Level ID Register */ | 578 | ARMREG_READ_INLINE(clidr, "p15,1,%0,c0,c0,1") /* Cache Level ID Register */ | |
570 | ARMREG_READ_INLINE(csselr, "p15,2,%0,c0,c0,0") /* Cache Size Selection Register */ | 579 | ARMREG_READ_INLINE(csselr, "p15,2,%0,c0,c0,0") /* Cache Size Selection Register */ | |
571 | ARMREG_WRITE_INLINE(csselr, "p15,2,%0,c0,c0,0") /* Cache Size Selection Register */ | 580 | ARMREG_WRITE_INLINE(csselr, "p15,2,%0,c0,c0,0") /* Cache Size Selection Register */ | |
572 | /* c1 registers */ | 581 | /* c1 registers */ | |
573 | ARMREG_READ_INLINE(cpacr, "p15,0,%0,c1,c0,2") /* Co-Processor Access Register */ | 582 | ARMREG_READ_INLINE(auxctl, "p15,0,%0,c1,c0,1") /* Auxiliary Control Register */ | |
574 | ARMREG_WRITE_INLINE(cpacr, "p15,0,%0,c1,c0,2") /* Co-Processor Access Register */ | 583 | ARMREG_WRITE_INLINE(auxctl, "p15,0,%0,c1,c0,1") /* Auxiliary Control Register */ | |
584 | ARMREG_READ_INLINE(cpacr, "p15,0,%0,c1,c0,2") /* Co-Processor Access Control Register */ | |||
585 | ARMREG_WRITE_INLINE(cpacr, "p15,0,%0,c1,c0,2") /* Co-Processor Access Control Register */ | |||
575 | /* c2 registers */ | 586 | /* c2 registers */ | |
576 | ARMREG_READ_INLINE(ttbr, "p15,0,%0,c2,c0,0") /* Translation Table Base Register 0 */ | 587 | ARMREG_READ_INLINE(ttbr, "p15,0,%0,c2,c0,0") /* Translation Table Base Register 0 */ | |
577 | ARMREG_WRITE_INLINE(ttbr, "p15,0,%0,c2,c0,0") /* Translation Table Base Register 0 */ | 588 | ARMREG_WRITE_INLINE(ttbr, "p15,0,%0,c2,c0,0") /* Translation Table Base Register 0 */ | |
578 | ARMREG_READ_INLINE(ttbr1, "p15,0,%0,c2,c0,1") /* Translation Table Base Register 1 */ | 589 | ARMREG_READ_INLINE(ttbr1, "p15,0,%0,c2,c0,1") /* Translation Table Base Register 1 */ | |
579 | ARMREG_WRITE_INLINE(ttbr1, "p15,0,%0,c2,c0,1") /* Translation Table Base Register 1 */ | 590 | ARMREG_WRITE_INLINE(ttbr1, "p15,0,%0,c2,c0,1") /* Translation Table Base Register 1 */ | |
580 | ARMREG_READ_INLINE(ttbcr, "p15,0,%0,c2,c0,2") /* Translation Table Base Register */ | 591 | ARMREG_READ_INLINE(ttbcr, "p15,0,%0,c2,c0,2") /* Translation Table Base Register */ | |
581 | ARMREG_WRITE_INLINE(ttbcr, "p15,0,%0,c2,c0,2") /* Translation Table Base Register */ | 592 | ARMREG_WRITE_INLINE(ttbcr, "p15,0,%0,c2,c0,2") /* Translation Table Base Register */ | |
582 | /* c5 registers */ | 593 | /* c5 registers */ | |
583 | ARMREG_READ_INLINE(dfsr, "p15,0,%0,c5,c0,0") /* Data Fault Status Register */ | 594 | ARMREG_READ_INLINE(dfsr, "p15,0,%0,c5,c0,0") /* Data Fault Status Register */ | |
584 | ARMREG_READ_INLINE(ifsr, "p15,0,%0,c5,c0,1") /* Instruction Fault Status Register */ | 595 | ARMREG_READ_INLINE(ifsr, "p15,0,%0,c5,c0,1") /* Instruction Fault Status Register */ | |
585 | /* c6 registers */ | 596 | /* c6 registers */ | |
586 | ARMREG_READ_INLINE(dfar, "p15,0,%0,c6,c0,0") /* Data Fault Address Register */ | 597 | ARMREG_READ_INLINE(dfar, "p15,0,%0,c6,c0,0") /* Data Fault Address Register */ | |
587 | ARMREG_READ_INLINE(ifar, "p15,0,%0,c6,c0,2") /* Instruction Fault Address Register */ | 598 | ARMREG_READ_INLINE(ifar, "p15,0,%0,c6,c0,2") /* Instruction Fault Address Register */ |
--- src/sys/arch/arm/include/vfpreg.h 2012/09/22 01:44:12 1.5
+++ src/sys/arch/arm/include/vfpreg.h 2012/09/22 19:45:53 1.6
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: vfpreg.h,v 1.5 2012/09/22 01:44:12 matt Exp $ */ | 1 | /* $NetBSD: vfpreg.h,v 1.6 2012/09/22 19:45:53 matt Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2008 ARM Ltd | 4 | * Copyright (c) 2008 ARM Ltd | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -35,38 +35,44 @@ | @@ -35,38 +35,44 @@ | |||
35 | /* FPSID regsiter */ | 35 | /* FPSID regsiter */ | |
36 | 36 | |||
37 | #define VFP_FPSID_IMP_MSK 0xff000000 /* Implementer */ | 37 | #define VFP_FPSID_IMP_MSK 0xff000000 /* Implementer */ | |
38 | #define VFP_FPSID_IMP_ARM 0x41000000 /* Implementer: ARM */ | 38 | #define VFP_FPSID_IMP_ARM 0x41000000 /* Implementer: ARM */ | |
39 | #define VFP_FPSID_SW 0x00800000 /* VFP implemented in SW */ | 39 | #define VFP_FPSID_SW 0x00800000 /* VFP implemented in SW */ | |
40 | #define VFP_FPSID_FMT_MSK 0x00600000 /* FLDMX/FSTMX Format */ | 40 | #define VFP_FPSID_FMT_MSK 0x00600000 /* FLDMX/FSTMX Format */ | |
41 | #define VFP_FPSID_FMT_1 0x00000000 /* Standard format 1 */ | 41 | #define VFP_FPSID_FMT_1 0x00000000 /* Standard format 1 */ | |
42 | #define VFP_FPSID_FMT_2 0x00200000 /* Standard format 2 */ | 42 | #define VFP_FPSID_FMT_2 0x00200000 /* Standard format 2 */ | |
43 | #define VFP_FPSID_FMT_WEIRD 0x00600000 /* Non-standard format */ | 43 | #define VFP_FPSID_FMT_WEIRD 0x00600000 /* Non-standard format */ | |
44 | #define VFP_FPSID_SP 0x00100000 /* Only single precision */ | 44 | #define VFP_FPSID_SP 0x00100000 /* Only single precision */ | |
45 | #define VFP_FPSID_ARCH_MSK 0x000f0000 /* Architecture */ | 45 | #define VFP_FPSID_ARCH_MSK 0x000f0000 /* Architecture */ | |
46 | #define VFP_FPSID_ARCH_V1 0x00000000 /* Arch VFPv1 */ | 46 | #define VFP_FPSID_ARCH_V1 0x00000000 /* Arch VFPv1 */ | |
47 | #define VFP_FPSID_ARCH_V2 0x00010000 /* Arch VFPv2 */ | 47 | #define VFP_FPSID_ARCH_V2 0x00010000 /* Arch VFPv2 */ | |
48 | #define VFP_FPSID_ARCH_V3_2 0x00020000 /* Arch VFPv3 (subarch v2) */ | |||
49 | #define VFP_FPSID_ARCH_V3 0x00030000 /* Arch VFPv3 (no subarch) */ | |||
50 | #define VFP_FPSID_ARCH_V3_3 0x00040000 /* Arch VFPv3 (subarch v3) */ | |||
48 | #define VFP_FPSID_PART_MSK 0x0000ff00 /* Part number */ | 51 | #define VFP_FPSID_PART_MSK 0x0000ff00 /* Part number */ | |
49 | #define VFP_FPSID_PART_VFP10 0x00001000 /* VFP10 */ | 52 | #define VFP_FPSID_PART_VFP10 0x00001000 /* VFP10 */ | |
50 | #define VFP_FPSID_PART_VFP11 0x00002000 /* VFP11 */ | 53 | #define VFP_FPSID_PART_VFP11 0x00002000 /* VFP11 */ | |
51 | #define VFP_FPSID_PART_VFP30 0x00003000 /* VFP30 */ | 54 | #define VFP_FPSID_PART_VFP30 0x00003000 /* VFP30 */ | |
52 | #define VFP_FPSID_VAR_MSK 0x000000f0 /* Variant */ | 55 | #define VFP_FPSID_VAR_MSK 0x000000f0 /* Variant */ | |
53 | #define VFP_FPSID_VAR_ARM10 0x000000a0 /* Variant ARM10 */ | 56 | #define VFP_FPSID_VAR_ARM10 0x000000a0 /* Variant ARM10 */ | |
54 | #define VFP_FPSID_VAR_ARM11 0x000000b0 /* Variant ARM11 */ | 57 | #define VFP_FPSID_VAR_ARM11 0x000000b0 /* Variant ARM11 */ | |
55 | #define VFP_FPSID_REV_MSK 0x0000000f /* Revision */ | 58 | #define VFP_FPSID_REV_MSK 0x0000000f /* Revision */ | |
56 | 59 | |||
57 | #define FPU_VFP10_ARM10E 0x410001a0 /* Really a VFPv2 part */ | 60 | #define FPU_VFP10_ARM10E 0x410001a0 /* Really a VFPv2 part */ | |
58 | #define FPU_VFP11_ARM11 0x410120b0 | 61 | #define FPU_VFP11_ARM11 0x410120b0 | |
59 | #define FPU_VFP30_CORTEXA9 0x41033090 | 62 | #define FPU_VFP_CORTEXA5 0x41023050 | |
63 | #define FPU_VFP_CORTEXA7 0x41023070 | |||
64 | #define FPU_VFP_CORTEXA8 0x410330c0 | |||
65 | #define FPU_VFP_CORTEXA9 0x41033090 | |||
60 | 66 | |||
61 | #define VFP_FPEXC_EX 0x80000000 /* Exception status bit */ | 67 | #define VFP_FPEXC_EX 0x80000000 /* Exception status bit */ | |
62 | #define VFP_FPEXC_EN 0x40000000 /* VFP Enable bit */ | 68 | #define VFP_FPEXC_EN 0x40000000 /* VFP Enable bit */ | |
63 | #define VFP_FPEXC_FP2V 0x10000000 /* FPINST2 instruction valid */ | 69 | #define VFP_FPEXC_FP2V 0x10000000 /* FPINST2 instruction valid */ | |
64 | #define VFP_FPEXC_VECITR 0x00000700 /* Vector iteration count */ | 70 | #define VFP_FPEXC_VECITR 0x00000700 /* Vector iteration count */ | |
65 | #define VFP_FPEXC_INV 0x00000080 /* Input exception flag */ | 71 | #define VFP_FPEXC_INV 0x00000080 /* Input exception flag */ | |
66 | #define VFP_FPEXC_UFC 0x00000080 /* Potential underflow flag */ | 72 | #define VFP_FPEXC_UFC 0x00000080 /* Potential underflow flag */ | |
67 | #define VFP_FPEXC_OFC 0x00000080 /* Potential overflow flag */ | 73 | #define VFP_FPEXC_OFC 0x00000080 /* Potential overflow flag */ | |
68 | #define VFP_FPEXC_IOC 0x00000080 /* Potential inv. op. flag */ | 74 | #define VFP_FPEXC_IOC 0x00000080 /* Potential inv. op. flag */ | |
69 | 75 | |||
70 | #define VFP_FPSCR_N 0x80000000 /* set if compare <= result */ | 76 | #define VFP_FPSCR_N 0x80000000 /* set if compare <= result */ | |
71 | #define VFP_FPSCR_Z 0x40000000 /* set if compare = result */ | 77 | #define VFP_FPSCR_Z 0x40000000 /* set if compare = result */ | |
72 | #define VFP_FPSCR_C 0x20000000 /* set if compare (=,>=,UNORD) result */ | 78 | #define VFP_FPSCR_C 0x20000000 /* set if compare (=,>=,UNORD) result */ |
--- src/sys/arch/arm/vfp/vfp_init.c 2012/09/22 01:44:12 1.6
+++ src/sys/arch/arm/vfp/vfp_init.c 2012/09/22 19:45:54 1.7
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: vfp_init.c,v 1.6 2012/09/22 01:44:12 matt Exp $ */ | 1 | /* $NetBSD: vfp_init.c,v 1.7 2012/09/22 19:45:54 matt Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2008 ARM Ltd | 4 | * Copyright (c) 2008 ARM Ltd | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -206,70 +206,79 @@ vfp_fpscr_handler(u_int address, u_int i | @@ -206,70 +206,79 @@ vfp_fpscr_handler(u_int address, u_int i | |||
206 | */ | 206 | */ | |
207 | void | 207 | void | |
208 | vfp_attach(void) | 208 | vfp_attach(void) | |
209 | { | 209 | { | |
210 | install_coproc_handler(VFP_COPROC, vfp_fpscr_handler); | 210 | install_coproc_handler(VFP_COPROC, vfp_fpscr_handler); | |
211 | } | 211 | } | |
212 | 212 | |||
213 | #else | 213 | #else | |
214 | void | 214 | void | |
215 | vfp_attach(void) | 215 | vfp_attach(void) | |
216 | { | 216 | { | |
217 | struct cpu_info * const ci = curcpu(); | 217 | struct cpu_info * const ci = curcpu(); | |
218 | const char *model = NULL; | 218 | const char *model = NULL; | |
219 | void *uh; | 219 | bool vfp_p = false; | |
220 | 220 | |||
221 | uh = install_coproc_handler(VFP_COPROC, vfp_test); | 221 | #ifdef FPU_VFP | |
222 | if (CPU_ID_ARM11_P(curcpu()->ci_arm_cpuid) | |||
223 | || CPU_ID_CORTEX_P(curcpu()->ci_arm_cpuid)) { | |||
224 | const uint32_t cpacr_vfp = CPACR_CPn(VFP_COPROC); | |||
225 | const uint32_t cpacr_vfp2 = CPACR_CPn(VFP_COPROC2); | |||
222 | 226 | |||
223 | undefined_test = 0; | 227 | /* | |
228 | * We first need to enable access to the coprocessors. | |||
229 | */ | |||
230 | uint32_t cpacr = armreg_cpacr_read(); | |||
231 | cpacr |= __SHIFTIN(CPACR_ALL, cpacr_vfp); | |||
232 | cpacr |= __SHIFTIN(CPACR_ALL, cpacr_vfp2); | |||
233 | armreg_cpacr_write(cpacr); | |||
224 | 234 | |||
225 | #ifdef FPU_VFP | 235 | /* | |
226 | uint32_t cpacr = armreg_cpacr_read(); | 236 | * If we could enable them, then they exist. | |
227 | cpacr &= ~__BITS(21,20); | 237 | */ | |
228 | cpacr &= ~__BITS(23,22); | 238 | cpacr = armreg_cpacr_read(); | |
229 | 239 | vfp_p = __SHIFTOUT(cpacr, cpacr_vfp2) != CPACR_NOACCESS | ||
230 | cpacr |= __SHIFTIN(1, __BITS(21,20)); | 240 | || __SHIFTOUT(cpacr, cpacr_vfp) != CPACR_NOACCESS; | |
231 | cpacr |= __SHIFTIN(1, __BITS(23,22)); | |||
232 | armreg_cpacr_write(cpacr); | |||
233 | cpacr = armreg_cpacr_read(); | |||
234 | if ((cpacr & __BITS(23,22)) == 0) { | |||
235 | aprint_normal_dev(ci->ci_dev, "NEON not present\n"); | |||
236 | } | |||
237 | if ((cpacr & __BITS(21,20)) == 0) { | |||
238 | aprint_normal_dev(ci->ci_dev, "VFP not present\n"); | |||
239 | } | 241 | } | |
240 | #endif | 242 | #endif | |
241 | 243 | |||
244 | void *uh = install_coproc_handler(VFP_COPROC, vfp_test); | |||
245 | ||||
246 | undefined_test = 0; | |||
247 | ||||
242 | const uint32_t fpsid = read_fpsid(); | 248 | const uint32_t fpsid = read_fpsid(); | |
243 | 249 | |||
244 | remove_coproc_handler(uh); | 250 | remove_coproc_handler(uh); | |
245 | 251 | |||
246 | if (undefined_test != 0) { | 252 | if (undefined_test != 0) { | |
247 | aprint_normal_dev(ci->ci_dev, "No VFP detected\n"); | 253 | aprint_normal_dev(ci->ci_dev, "No VFP detected\n"); | |
248 | install_coproc_handler(VFP_COPROC, vfp_fpscr_handler); | 254 | install_coproc_handler(VFP_COPROC, vfp_fpscr_handler); | |
249 | ci->ci_vfp_id = 0; | 255 | ci->ci_vfp_id = 0; | |
250 | return; | 256 | return; | |
251 | } | 257 | } | |
252 | 258 | |||
253 | ci->ci_vfp_id = fpsid; | 259 | ci->ci_vfp_id = fpsid; | |
254 | switch (fpsid & ~ VFP_FPSID_REV_MSK) { | 260 | switch (fpsid & ~ VFP_FPSID_REV_MSK) { | |
255 | case FPU_VFP10_ARM10E: | 261 | case FPU_VFP10_ARM10E: | |
256 | model = "VFP10 R1"; | 262 | model = "VFP10 R1"; | |
257 | break; | 263 | break; | |
258 | case FPU_VFP11_ARM11: | 264 | case FPU_VFP11_ARM11: | |
259 | model = "VFP11"; | 265 | model = "VFP11"; | |
260 | break; | 266 | break; | |
261 | case FPU_VFP30_CORTEXA9: | 267 | case FPU_VFP_CORTEXA5: | |
262 | model = "NEON MPE w/ VFP 3.0"; | 268 | case FPU_VFP_CORTEXA7: | |
269 | case FPU_VFP_CORTEXA8: | |||
270 | case FPU_VFP_CORTEXA9: | |||
271 | model = "NEON MPE (VFP 3.0+)"; | |||
263 | break; | 272 | break; | |
264 | default: | 273 | default: | |
265 | aprint_normal_dev(ci->ci_dev, "unrecognized VFP version %x\n", | 274 | aprint_normal_dev(ci->ci_dev, "unrecognized VFP version %x\n", | |
266 | fpsid); | 275 | fpsid); | |
267 | install_coproc_handler(VFP_COPROC, vfp_fpscr_handler); | 276 | install_coproc_handler(VFP_COPROC, vfp_fpscr_handler); | |
268 | return; | 277 | return; | |
269 | } | 278 | } | |
270 | 279 | |||
271 | if (fpsid != 0) { | 280 | if (fpsid != 0) { | |
272 | aprint_normal("vfp%d at %s: %s\n", | 281 | aprint_normal("vfp%d at %s: %s\n", | |
273 | device_unit(curcpu()->ci_dev), device_xname(curcpu()->ci_dev), | 282 | device_unit(curcpu()->ci_dev), device_xname(curcpu()->ci_dev), | |
274 | model); | 283 | model); | |
275 | } | 284 | } |