diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2021-12-30 20:48:26 +0200 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2021-12-30 20:48:26 +0200 |
| commit | 6f052e236715846b1a14f9fe59f89346efb809e6 (patch) | |
| tree | c1bbca5a063c428f65c46b34aaf4dbf47e61c213 /include | |
| parent | 4f4d9fdc89c27aa3346467a24b621954f4564d3b (diff) | |
| download | kmi-6f052e236715846b1a14f9fe59f89346efb809e6.tar.gz kmi-6f052e236715846b1a14f9fe59f89346efb809e6.zip | |
Add initial version of device memory mapping
Diffstat (limited to 'include')
| -rw-r--r-- | include/apos/dev.h | 16 | ||||
| -rw-r--r-- | include/apos/vmem.h | 17 |
2 files changed, 32 insertions, 1 deletions
diff --git a/include/apos/dev.h b/include/apos/dev.h new file mode 100644 index 0000000..1e710a1 --- /dev/null +++ b/include/apos/dev.h @@ -0,0 +1,16 @@ +#ifndef APOS_DEV_H +#define APOS_DEV_H + +#include <apos/types.h> +#include <apos/vmem.h> + +extern pm_t __pre_base; +extern pm_t __pre_top; +extern pm_t __post_base; +extern pm_t __post_top; + +void init_devmem(pm_t ram_base, pm_t ram_top); +vm_t alloc_devmem(struct tcb *t, pm_t dev_start, size_t bytes, uint8_t flags); +void free_devmem(struct tcb *t, vm_t dev_start); + +#endif /* APOS_DEV_H */ diff --git a/include/apos/vmem.h b/include/apos/vmem.h index 87a3aa6..8057631 100644 --- a/include/apos/vmem.h +++ b/include/apos/vmem.h @@ -43,6 +43,7 @@ void map_vmem(struct vm_branch *branch, pm_t paddr, vm_t vaddr, uint8_t flags, enum mm_order order); void unmap_vmem(struct vm_branch *branch, vm_t vaddr); + int mod_vmem(struct vm_branch *branch, vm_t vaddr, pm_t paddr, uint8_t flags); int stat_vmem(struct vm_branch *branch, vm_t vaddr, pm_t *paddr, enum mm_order *order, uint8_t *flags); @@ -66,9 +67,23 @@ vm_t alloc_uvmem(struct tcb *r, size_t size, uint8_t flags); vm_t alloc_fixed_uvmem(struct tcb *r, vm_t start, size_t size, uint8_t flags); void free_uvmem(struct tcb *r, vm_t a); -vm_t map_fill_region(struct vm_branch *b, vm_t start, size_t bytes, uint8_t flags); +vm_t map_fill_region(struct vm_branch *b, + int (*vmem_handler)(struct vm_branch *, pm_t *, vm_t, uint8_t, enum mm_order), + pm_t offset, vm_t start, size_t bytes, uint8_t flags); + +#define map_allocd_region(b, start, bytes, flags)\ + map_fill_region(b, &alloc_mem_wrapper, 0, start, bytes, flags) + +#define unmap_freed_region(b, start, bytes)\ + map_fill_region(b, &free_mem_wrapper, 0, start, bytes, 0) + +int alloc_mem_wrapper(struct vm_branch *b, pm_t *offset, vm_t vaddr, uint8_t flags, enum mm_order order); +int free_mem_wrapper(struct vm_branch *b, pm_t *offset, vm_t vaddr, uint8_t flags, enum mm_order order); size_t uvmem_size(); void set_uvmem_size(size_t s); +/* not entirely sure if this is clean enough, but it'll do for now. */ +struct sp_mem *sp_used_find(struct sp_reg_root *r, vm_t start); + #endif /* APOS_VMEM_H */ |
