From: Joe deBlaquiere (jadb@redhat.com)
Date: Mon Jan 22 2001 - 00:48:59 EST
The values are pushed to the stack before interrupts are turned on and
restored with ints turned off in ret_from_syscall...
Zhu, Yaozong wrote:
> Actually if SWI is executed in SVC mode, the previous lr_SVC and spsr_SVC are lost, right?
> Quoted from ARM7TDMI data sheet:
> "
> Note that the link mechanism is not re-entrant, so if the supervisor code
> wishes to use software interrupts within itself it must first save a copy of the
> return address and SPSR.
> "
> -----Original Message-----
> From: owner-uclinux-dev@uClinux.org
> [mailto:owner-uclinux-dev@uClinux.org]On Behalf Of Joe deBlaquiere
> Sent: Monday, January 22, 2001 11:30 AM
> To: uclinux-dev@uClinux.org
> Subject: Re: [uClinux-dev] About system call code in arm-uclinux, Aplio
> version
>
>
> Sure, you can make syscalls in a system thread, you just have to make
> sure you have timers, interrupts and all configured (i.e. not at the .
> It would probably be more appropriate to put the code into the init
> thread or even better to run it as /bin/init.
>
> Now that I look at it a little deeper, I doesn't matter what context you
> came from. If you look at the SWI entry point (below), it saves off
> whatever CPSR was stuffed into the SPSR at interrupt. So if you do a SWI
> from SVC mode, it saves off the SVC mode PSR.
>
> vector_swi: sub sp, sp, #S_FRAME_SIZE
> stmia sp, {r0 - r12} @ Calling r0 - r12
> add r8, sp, #S_PC
> stmdb r8, {sp, lr}^ @ Calling sp, lr <<<<<< Look HERE, Joe. sp and lr here are sp_USR and lr_USR
> mov r7, r0
> mrs r6, spsr <<<<<<< saves whichever PSR called
> mov r5, lr
> stmia r8, {r5, r6, r7} @ Save calling
> PC, CPSR, OLD_R0
>
> Looking a little father in, the ret_from_syscall routines (below) which
> perform a context restore really doesn't care either.
>
> Lret_no_check: mrs r0, cpsr @ disable IRQs
> orr r0, r0, #I_BIT
> msr cpsr, r0
> ldr r0, [sp, #S_PSR] @ Get calling cpsr
> msr spsr, r0
> ldmia sp, {r0 - lr}^ @ Get calling r0
> - lr
> mov r0, r0
> add sp, sp, #S_PC
> ldr lr, [sp], #S_FRAME_SIZE - S_PC @ Get PC and
> jump over PC, PSR, OLD_R0
> movs pc, lr
>
>
>
> Zhu, Yaozong wrote:
>
>
>> Hi Joe,
>> To put my question in another way: can system calls( swi intructions indeed ) be called by kernel code? It seems that SWI handling code are written to service USER mode calls. The init may run in USER mode. But clone system calls must be called from kernel mode code(in start_kernel) to make init run.
>>
>> -----Original Message-----
>> From: owner-uclinux-dev@uClinux.org
>> [mailto:owner-uclinux-dev@uClinux.org]On Behalf Of Joe deBlaquiere
>> Sent: Sunday, January 21, 2001 11:30 PM
>> To: uclinux-dev@uClinux.org
>> Subject: Re: [uClinux-dev] About system call code in arm-uclinux, Aplio
>> version
>>
>>
>> I'm not entirely sure about this, but I think the answer to this is that
>> the kernel_thread() call creates a thread which runs as a user mode
>> process (using the clone call). Therefore init() is not being run in SVC
>> mode.
>>
>> Zhu, Yaozong wrote:
>>
>>
>>
>>> Hi all,
>>> It seems that start_kernel(init/main.c) runs in SVC mode. And in start_kernel, kernel_thread(init, NULL, 0) is called which does two swi's . My humble question is , when doing system calls from SVC mode, vector_swi(arch/armnommu/kernel/entry-armv.S) saves and restores USER mode registers, and _ret_from_sys_call does restore sp_SVC and spsr_SVC, but lr_SVC is lost, isn't this a problem, or I am wrong?
>>>
>>>
>>>
>>>
>>> This message resent by the uclinux-dev@uclinux.org list server http://www.uClinux.org/
>>
--
Joe deBlaquiere
Red Hat, Inc.
307 Wynn Drive
Huntsville AL, 35805
voice : (256)-704-9200
fax : (256)-837-3839
This message resent by the uclinux-dev@uclinux.org list server http://www.uClinux.org/
This archive was generated by hypermail 2.1.4 : Thu Sep 19 2002 - 13:19:27 EDT