Arm Community
Site
Search
User
Site
Search
User
Groups
Arm Research
DesignStart
Education Hub
Graphics and Gaming
High Performance Computing
Innovation
Multimedia
Open Source Software and Platforms
Physical
Processors
Security
System
Software Tools
TrustZone for Armv8-M
中文社区
Blog
Announcements
Artificial Intelligence
Automotive
Healthcare
HPC
Infrastructure
Innovation
Internet of Things
Machine Learning
Mobile
Smart Homes
Wearables
Forums
All developer forums
IP Product forums
Tool & Software forums
Pelion IoT Platform
Support
Open a support case
Documentation
Downloads
Training
Arm Approved program
Arm Design Reviews
Community Help
More
Cancel
Developer Community
Tools and Software
Software Tools
Jump...
Cancel
Software Tools
Arm Development Studio forum
SMC instruction
Tools, Software and IDEs blog
Forums
Videos & Files
Help
Jump...
Cancel
New
Replies
2 replies
Subscribers
127 subscribers
Views
2605 views
Users
0 members are here
Related
SMC instruction
Offline
Dm Sh
over 7 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 7 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
Reply
Cancel
Offline
sandemuk 01
over 7 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
Reply
Cancel
More questions in this forum
By title
By date
By reply count
By view count
By most asked
By votes
By quality
Descending
Ascending
All recent questions
Unread questions
Questions you've participated in
Questions you've asked
Unanswered questions
Answered questions
Questions with suggested answers
Questions with no replies
Suggested Answer
Positioning a function in a Position Independent Executable for ARMV8
0
5720
views
3
replies
Latest
1 month ago
by
Stephen Theobald
Answered
Link a pure binary file to image with scatter file
0
5676
views
3
replies
Latest
1 month ago
by
Ronan Synnott
Answered
Failed to read contents of Internal RAM L1-I_DATA in ARM DS
0
Arm Development Studio
Cache
Debug and Trace Services Layer (DTSL)
9915
views
23
replies
Latest
1 month ago
by
Boon Khai
Suggested Answer
DS-5 connect fail when cortex-r5 is in lock-step mode
0
8258
views
10
replies
Latest
2 months ago
by
Stuart Hirons
Suggested Answer
On Cortex-M4F microcontrollers: is fixed point math faster or floating point?
0
7927
views
10
replies
Latest
2 months ago
by
Ronan Synnott
<
>
View all questions in Arm Development Studio forum