WIP: hardware abstraction code reorganisation

Please do not work on this commit, it will be deleted and a new
one will come when the work is done