diff options
author | emilia <emilia@vegaa.systems> | 2023-08-27 22:10:32 +0000 |
---|---|---|
committer | emilia <emilia@vegaa.systems> | 2023-08-27 22:10:32 +0000 |
commit | 846f7bffcaa69f72bcbee43f95c4ba144a27c166 (patch) | |
tree | d3321ca54b92c9a3ed8c743e6dc86504e2026d8d /sys/include | |
parent | 7f2668d6fe3b7ce82c72d1603f59ec124d1a354b (diff) |
kernel: mmio: Check for physical addresses
This commit adds extra documentation to mmio_write<n>()
as well as adding checks for physical addresses and handling
them properly.
git-svn-id: https://svn.vegaa.systems/svn/vega-Vega/trunk@38 a8a8aea2-181d-ee11-89e8-15fd0e089fc4
Diffstat (limited to 'sys/include')
-rw-r--r-- | sys/include/sys/mmio.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/sys/include/sys/mmio.h b/sys/include/sys/mmio.h index ea0439f..65e423c 100644 --- a/sys/include/sys/mmio.h +++ b/sys/include/sys/mmio.h @@ -33,11 +33,28 @@ #define _SYS_MMIO_H_ #include <sys/types.h> +#include <vm/vm.h> +/* + * mmio_write<n> - Writes to MMIO address with specific size + * + * @addr: Address to write to. + * @val: Value to write. + * + * These functions will add the higher half + * offset (VM_HIGHER_HALF) if the MMIO address + * is less than VM_HIGHER_HALF as it'll be safe + * to assume it's a physical address. Page faults + * from writes could be due to the resulting virtual + * address not being mapped. + */ #define _MMIO_WRITE_TYPE(TYPE, SUFFIX) \ static inline void \ mmio_write##SUFFIX(uintptr_t addr, TYPE val) \ { \ + if (addr < VM_HIGHER_HALF) { \ + addr += VM_HIGHER_HALF; \ + } \ *(volatile TYPE *)addr = val; \ } |