[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [microblaze-uclinux] [patch test] syscall interface cleanup
Hi Yashi,
Yasushi SHOJI wrote:
> John Williams wrote:
>
>>Microblaze has a dedicated "break" instruction - brki - which is much
>>preferred over branch, because it is the closest thing we have to a real
>>"kernel trap" instruction. In particular, it sets a bit in the flags
>>register (BIP - break in progress) that masks interrupts. This supports
>>a cleaner approach in the kernel system call entry point.
>
>
> I thought "break" inst. is for debugger. I haven't look at you patch
> just yet, but does it work for both trap _and_ break?
Sorry I should have explained better.
Yes, both syscall and debug trap are now invoked with brki instruction.
syscall: brki r14, 0x08
db_trap: brki r14, 0x30 (brki instruction written into program code by
debugger, then removed after the debug trap handler.
In a new version of the patch (coming soon) I'm changing over to use r14
as the link register for syscalls, instead of r17 as it is currently.
r17 is used by the hardware exceptions, so there is a chance of
corruption if a non-maskable HW exception occurs after syscall
invokation but before state save completes...
r14 is safe because the BRKI sets BIP bit in flags, which masks
interrupts. No interrupt can occur until after state save, and the
syscall/db_trap return address is safely saved.
Also following some discussions with Goran I'll change the debug trap to
use vector 0x30, rather than 0x18 as currently used. 0x18 is
auto-vectored from an NMI or ext_brk hardware break, and so should not
be doubled up with the debug trap. 0x20 is used by the new microblaze
exceptions (unaligned access, divide by zero, page fault... ;-) , and
I'll leave 0x28 free in case Goran decides to add any more HW exception
vectors :)
0x30 seems like the best solution. It's technically quite ugly to mux
the syscall and debug traps onto the same vector, but it's not a good
idea anyway because it would slow down syscall handling doing the demux.
Hope this clears things up a bit.
John
BTW There's a subtle but terrible bug in the first test patch that
causes all user programs to be executed with interrupts disabled - oops!
This turns uClinux into a cooperatively multi-tasked application
environment, all processes run until they yield by making a system call ;-)
I'll send the fixed version shortly, with the r14 and exception/trap
vector changes included.
___________________________
microblaze-uclinux mailing list
microblaze-uclinux@itee.uq.edu.au
Project Home Page : http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
Mailing List Archive : http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/