Arm Community
Site
Search
User
Site
Search
User
Groups
Research Collaboration and Enablement
DesignStart
Education Hub
Innovation
Open Source Software and Platforms
Forums
AI and ML forum
Architectures and Processors forum
Arm Development Platforms forum
Arm Development Studio forum
Arm Virtual Hardware forum
Automotive forum
Compilers and Libraries forum
Graphics, Gaming, and VR forum
High Performance Computing (HPC) forum
Infrastructure Solutions forum
Internet of Things (IoT) forum
Keil forum
Morello Forum
Operating Systems forum
SoC Design and Simulation forum
中文社区论区
Blogs
AI and ML blog
Announcements
Architectures and Processors blog
Automotive blog
Graphics, Gaming, and VR blog
High Performance Computing (HPC) blog
Infrastructure Solutions blog
Innovation blog
Internet of Things (IoT) blog
Operating Systems blog
Research Articles
SoC Design and Simulation blog
Tools, Software and IDEs blog
中文社区博客
Support
Arm Support Services
Documentation
Downloads
Training
Arm Approved program
Arm Design Reviews
Community Help
More
Cancel
Support forums
Arm Development Studio forum
SMC instruction
Jump...
Cancel
Locked
Locked
Replies
2 replies
Subscribers
121 subscribers
Views
4068 views
Users
0 members are here
Options
Share
More actions
Cancel
Related
How was your experience today?
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion
SMC instruction
Offline
Dm Sh
over 9 years ago
Note: This was originally posted on 22nd January 2013 at
http://forums.arm.com
Good day.
I have a question - where I can get the #immediate value (4bit) in Secure Monitor Exception Handler, when called SMC instruction with non zero parametr - #imm-4 ?
Don't found this value in any registers.
From ARM documentation.
-------------------------------------
SMC
Secure Monitor Call.
Syntax
SMC{
cond
}
#imm4
where:
[i]imm4
[/i]is a 4-bit immediate value. This is ignored by the ARM processor, but can be used by the SMC exception handler to determine what service is being requested.
Thanks.
Offline
Peter Harris
over 9 years ago
Note: This was originally posted on 27th January 2013 at
http://forums.arm.com
Bear in mind that the SMC instruction is used to switch worlds, so you tend to get an address in the "other world's" virtual address map in LR, which in many cases may not be the same as the currently running software. Direct access of the address in LR is therefore unlikely to do what you want - it may well page fault, or at least return utterly unrelated data.
This generally makes it very hard to use this feature of the SMC instruction; at least it makes it more hassle than it is worth - in most cases putting a constant in a register by hand as part of the cross-world smc call API is much easier.
HTH,
Iso
Cancel
Up
0
Down
Cancel
Offline
sandemuk 01
over 9 years ago
Note: This was originally posted on 22nd January 2013 at
http://forums.arm.com
The immediate value passed with the SMC instruction can be retrieved by reading back the SMC instruction opcode. The address of SMC instruction can known from the link register of monitor mode. Consider the following code sequence:
IA Instructions
------------------------------------------
... ...
0x840 i0
0x844 i1
0x848 SMC #10
0x84C i3
.... ...
where IA is the instruction address
When the SMC instruction is executed, a software exception is generated changing the CPU state with LR_mon/R14_mon getting updated with 0x84C (basically address of SMC instruction+4 irrespective of whether the SMC was executed in ARM or Thumb mode). So in the monitor exception handler, we can read back the SMC instruction opcode and extract the immediate value in the following way:
... initial code for monitor handler....
LDR r0, [r14, # - 4]
AND r0, r0, #0xF
(The immediate value is encoded in bits[3:0] of SMC instruction for both ARM and Thumb encoding)
Hope this helps.
Cancel
Up
0
Down
Cancel