SYSTEM function for special register
SYSTEM function for special register
Hi,
I want to set some registers which can be only accessed via MSR instructions.
So where can i find regarding SYSTEM functions for it ?
Thanks,
Marc
I want to set some registers which can be only accessed via MSR instructions.
So where can i find regarding SYSTEM functions for it ?
Thanks,
Marc
-
- Site Admin
- Posts: 525
- Joined: Fri Dec 31, 2010 12:30 pm
- Contact:
Re: SYSTEM function for special register
You can construct any 32-bit ARM Thumb-2 instruction (including illegal ones!) using SYSTEM.EMIT. See the source code of Traps.mod or Main.mod (Astrobe for Cortex-M4/M7 only) for examples of its use. Use at your own risk.
Re: SYSTEM function for special register
Yes I know, but why there exists a convenient SYSTEM.VMSR() function but not a more useful SYSTEM.MSR() ?
-
- Site Admin
- Posts: 525
- Joined: Fri Dec 31, 2010 12:30 pm
- Contact:
Re: SYSTEM function for special register
We were not aware that MSR is more useful than VMSR. What sort of applications are you hoping to use it for?
Re: SYSTEM function for special register
I'm developing on a bare metal M4 target (Apollo-2).
According to ARM prog. manual all the registers " APSR, IPSR, EPSR, IEPSR, IAPSR, EAPSR, PSR, MSP, PSP, PRIMASK, BASEPRI, BASEPRI_MAX, FAULTMASK, or CONTROL" are MSR /MRS accessible only , so quit alot ...
According to ARM prog. manual all the registers " APSR, IPSR, EPSR, IEPSR, IAPSR, EAPSR, PSR, MSP, PSP, PRIMASK, BASEPRI, BASEPRI_MAX, FAULTMASK, or CONTROL" are MSR /MRS accessible only , so quit alot ...
Re: SYSTEM function for special register
An application related example, is the global interrupt en/disable set in the PRIMASK register.
-
- Site Admin
- Posts: 525
- Joined: Fri Dec 31, 2010 12:30 pm
- Contact:
Re: SYSTEM function for special register
OK - thanks for the info. I would use SYSTEM.EMIT in one-line helper procedures for specialised tasks such as these. I haven't tested the following but this should give you a good start. They rely on the fact that register r11 is used for single parameters / return results from leaf procedures. Use the gnu assembler gas to ascertain the hex value of each instruction.
Code: Select all
MODULE MSRExample;
IMPORT SYSTEM;
PROCEDURE* SetPRIMASK(i: INTEGER);
BEGIN
(* MSR PRIMASK, r11 *)
SYSTEM.EMIT(08BF31088H)
END SetPRIMASK;
PROCEDURE* SetBASEPRI(i: INTEGER);
BEGIN
(* MSR BASEPRI, r11 *)
SYSTEM.EMIT(08BF31188H)
END SetBASEPRI;
PROCEDURE* SetFAULTMASK(i: INTEGER);
BEGIN
(* MSR FAULTMASK, r11 *)
SYSTEM.EMIT(08BF31388H)
END SetFAULTMASK;
PROCEDURE* PRIMASK(): INTEGER;
VAR i: INTEGER;
BEGIN
(* MRS r11, PRIMASK *)
SYSTEM.EMIT(0EFF31088H);
RETURN i
END PRIMASK;
PROCEDURE* BASEPRI(): INTEGER;
VAR i: INTEGER;
BEGIN
(* MRS r11, BASEPRI *)
SYSTEM.EMIT(0EFF31188H)
RETURN i
END BASEPRI;
PROCEDURE* FAULTMASK(): INTEGER;
VAR i: INTEGER;
BEGIN
(* MRS r11, FAULTMASK *)
SYSTEM.EMIT(0EFF31388H)
RETURN i
END FAULTMASK;
END MSRExample.
Re: SYSTEM function for special register
This way round, it's rather tedious for every special register but okay, I understand.