diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2026-01-25 17:14:53 +0200 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2026-01-25 17:14:53 +0200 |
| commit | cd41ed1758f4842d7b78870385e16b579cc89c38 (patch) | |
| tree | 271e1b437ec5a1511f4ffa400da447122576b94b /include | |
| parent | e8a7fe3bd5c40168d531a6a4f00a7417a278d58c (diff) | |
| download | kmi-master.tar.gz kmi-master.zip | |
+ Add tests and fix virtual mapping, this is enough to start writing
proper userspace drivers
Diffstat (limited to 'include')
| -rw-r--r-- | include/kmi/dmem.h | 23 | ||||
| -rw-r--r-- | include/kmi/mem.h | 3 | ||||
| -rw-r--r-- | include/kmi/syscalls.h | 4 |
3 files changed, 28 insertions, 2 deletions
diff --git a/include/kmi/dmem.h b/include/kmi/dmem.h index 697e55a..ec3e330 100644 --- a/include/kmi/dmem.h +++ b/include/kmi/dmem.h @@ -41,10 +41,33 @@ vm_t alloc_devmem(struct tcb *p, pm_t dev_start, size_t bytes, vmflags_t flags); /** * Free direct device mapping. * + * Frees both the uvmem and the underlying physical + * memory, can be called from syscall handler for example. + * * @param p Process to free mapping from. * @param dev_start Start of allocation. * @return \ref OK when succesful, \c ERR_NF when mapping not found. */ stat_t free_devmem(struct tcb *p, vm_t dev_start); +/** + * Free direct device mapping when the memory region is known. + * + * Arguably this means that the responsibilities of uvmem/vmem/dmem are not as + * nicely defined as I would like and they all kind of step on eachother's toes + * at the moment but good enough for right now, allows starting to write drivers in + * userspace. + * + * Note that at least currently this function has some strong assumptions about + * when it can be called, namely that the process must own the region and that + * there can be no external references to it. In other words, should only be + * called when the underlying physical memory should be freed. + * Does NOT free the uvmem of the region, only the underlying physical memory. + * + * @param p Process to free mapping from. + * @param m Memory region previously known to be a device memory mapping. + * @return \ref OK when succesful, \c ERR_INVAL otherwise. + */ +stat_t free_known_devmem(struct tcb *p, struct mem_region *m); + #endif /* KMI_DEV_H */ diff --git a/include/kmi/mem.h b/include/kmi/mem.h index 8c66eb5..129ae5e 100644 --- a/include/kmi/mem.h +++ b/include/kmi/mem.h @@ -188,6 +188,9 @@ size_t page_shift(); /** Memory region is private but not backed by memory. */ #define MR_NONBACKED (1 << (ARCH_VP_FLAGS + 3)) +/** Memory region in device memory region */ +#define MR_DEV (1 << (ARCH_VP_FLAGS + 4)) + /** @} */ /** diff --git a/include/kmi/syscalls.h b/include/kmi/syscalls.h index 30e46be..8921343 100644 --- a/include/kmi/syscalls.h +++ b/include/kmi/syscalls.h @@ -47,8 +47,8 @@ enum sys_code { /** Request memory from anywhere. */ SYS_REQ_MEM, - /** Request memory with physical address. */ - SYS_REQ_PMEM, + /** Request device memory, i.e. some physical address outside RAM. */ + SYS_REQ_DMEM, /** Request memory at fixed virtual address. */ SYS_REQ_FIXMEM, |
