Before you start to write device drivers I remind you that it is not possible to just write and read the peripheral registers via pointers. The compiler will do optimizations like omit reads and writes or reorder them.

My very simple uart driver is here:
https://bitbucket.org/timosi/minlibd/src/15e88941c534a19e753fa0eebcd053b17392b7ad/tools/main/uart.d?at=default

and gpio driver is here:
https://bitbucket.org/timosi/minlibd/src/15e88941c534a19e753fa0eebcd053b17392b7ad/tools/main/gpio.d?at=default

My work is based on the feature that a shared variable is marked as volatile in gcc. This feature is buggy and should not be used in the future. The official way is to use library functions to access registers but I think this results to horrible looking code.

This issue has currently stopped my work with device drivers. I would like to hear from compiler developers what is the idiomatic D way to do this. Someone might then make an sample driver and after discussion we all could start write drivers the same way.


Reply via email to