move more functions to generic code
restructuring types ready to share
move some types to generic code
add stub bsd types file