Switch from USER-Mode to SVC-Mode via SWI

OP #4085138
Hey,

I am trying to program a CORTEX A9 Processor with ARM and a GCC/GNU
toolchain.

At first the processor is in SVC-Mode then I want to switch to User-Mode
and run a user-program.
My first try is only to switch from SVC- to User-Mode and then calling a
SWI to get back to SVC-Mode.
Without changing to User-Mode everything with the SWI and the returns
works well, but if I change to User-Mode everything breaks down.

My questions are:

Needs the program a User-Stack if I only switch to User-Mode and in the
next step I call the SWI?

Which registers  must I save bevor switching to User-Mode?

I added two files: One is the swiHandler.c and the other one called:
beforeUserMode_test.s, switches to the User-Mode and then calls the SWI.
I think I Need to save some pointer in this file and restore them at the
right point again, but I do not know when I have to do this.

I am new here and if you need more details to my problem please write
what you need and i will post it.

Thanks for helping me

Andi
Attached files:

Reply

A question of your own? This thread is over 11 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.