lowlevel-z80-thunked: Fix pre-emption crashes
authorAlan Cox <alan@linux.intel.com>
Fri, 16 Nov 2018 20:56:49 +0000 (20:56 +0000)
committerAlan Cox <alan@linux.intel.com>
Fri, 16 Nov 2018 20:56:49 +0000 (20:56 +0000)
commitea2b1eec242acd0fee7d392f2ec326148c721e90
treecd71cfcf3ccc818640763ad1adf411b6dd67f735
parente892aaf0f69a1199d8c4e6b6efa3a435182ceaad
lowlevel-z80-thunked: Fix pre-emption crashes

This changes the way things work between the stubs and core code as they were
broken.

The stubs are now responsible for saving all the register state on the user
stack. The istack cannot be used for this as it was before because it may be
blown away by another interrupt. Instead the stubs carefully shuffle the two
bytes of return address onto the kstack of the process and return on that stack
in the pre-emption case.

It's not pretty but it's hard to do anything more elegant, and speedwise it's
a fast way to handle it.

A 'You are not expected to understand this code' moment, but it's buried in
support assembly code that nobody else has to understand.
Kernel/lowlevel-z80-thunked.s
Kernel/platform-sam/README
Kernel/platform-sam/sam.s